Results for
Hello,
I am setting up a home energy monitoring system, all started from a blank sheet in arduino and its really working very well.
I would like to send data to thinkspeak which is not time dependant, i.e. send the X and Y values and format as a bar graph. The reason is, i have 12 channels monitoring energy (Wh) and i have this in an array which i plot on a local LCD and throughout the day the bars grow in height as the usage attributed to that channel grows. How can i do something similar in thing speak which by default applies a time stamp to received data.
Very simply, each channel has an ID (0-11) and a number associated with the accumulative Wh. I have a similar thing in excel for development where my serial port data is saved to a csv which excell imports every minute and updates a bar graph a bit like this;

Ive had a good look (perhaps not good enough!) and i just cant see how this may be acheived with thingspeak without a clumbersome combination of 2 channels (given each channel has 8 fields) and then using a matlab visualisation to pull it all together. Perhaps its not has hard / messy as it sounds? I am paid user so can create extra channels if required.
Thanks,
Stuart
How do i collect data from a website like weather.com and use it in a channel? I need the current weather on a specific location (including storms, hail etc.) but i couldn't find a way to do it.
Connection: close
<html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
</body>
</html>
CLOSED
Hello,
I have a dfrobot microbit environment science extension board labelled as (v3.0)
I have tried to publish data to my thingspeak channel. All is well configurated in thingspeak.
I have read the tutorial and unfortunately I'm not able to publish any data on the channel with the extension board...
I've tried manualy with my firefox browser “https://api.thingspeak.com/update?api_key=xxxxxxxxxxxxxx&field1=0” and it works fine
But in the makecode program it does'nt …
My program looks like this, what is wrong ???
Any help will be much appreciated and by the way sorry for my bad english

%This is the code. I have to introduce a small value, for example, e = 0.01
%and the loop has to stop when de difference in absolue value between a1
%and pi is less than that quantity. But it never stops and i dont know why.
%Hope you can help me. I appreciate it.
function [a1,a2,i,j] = ejercicio06(e)
i=2;
j=2;
p(1) = e+1;
s(1) = e+1;
while p(i-1) > e
a1 = (1./((4.*i+1).*(4.*i+3)));
a1=8*sum(a1);
p(i) = abs(a1-pi);
i = i+1;
end
disp('hola este bucle se ha terminado')
while s(j-1) > e
a2 = (1./(1+j).^2);
a2 = sqrt(6*sum(a2));
s(j) = abs(a2-pi);
j = j+1;
end
end
Hello. I want to send the data that I have collected from the sensors and that is displayed on ThingSpeak to a databse in Firebase. How can I do it? I know I can use the REST API but where should I code the fetch? Thanks.
I can upload an image using postman. But when I try it with my rpi the image never shows. I receive status code 202. Then the current image from postman goes blank. Tells me the post sort of worked... Does anyone have working python3 code that they can share?
Last update is Friday March 10th. It appears from this end that the WS is correctly sending data.
If I can get Arduino running again I will try recompiling the code and update the board.
Hello people,
I made a program to read a dataset from JSON and make an API request to Thingspeak (bulk_write).
After the transmission I display the response of the request, which is 202 (compliant data).
My data updates fine on my Thingspeak channel but the longitude and latitude fields do not change.
Do you have any explanation for this problem?
Here is the code:
import json
import requests
import time
apiKey = "xxxxxxxxxxxxxxxx"
channel_ID = "xxxxxxx"
url = "https://api.thingspeak.com/channels/" + channel_ID + "/bulk_update.json" # ThingSpeak server settings
message_buffer = []
message = {}
while True:
f = open("data.json", "r")
jsonContent = f.read()
objJson = json.loads(jsonContent)
message['delta_t'] = 15
message['field1'] = (objJson['GPS']['speed'])
message['field2'] = (objJson['GROVE'][3]['degNord'])
message['field3'] = (objJson['GIROUETTE']['degVent'])
message['latitude'] = str((objJson['GPS']['latitude']))
message['longitude'] = str((objJson['GPS']['longitude']))
message['elevation'] = 100
latitude = (objJson['GPS']['latitude'])
longitude = (objJson['GPS']['longitude'])
#print(latitude)
#print(longitude)
message_buffer.append(message)
bulk_data = json.dumps({'write_api_key':apiKey,'updates':message_buffer})
print(bulk_data)
message_buffer = []
request_headers = {"User-Agent":"mw.doc.bulk-update","Content-Type":"application/json","Content-Length":str(len(bulk_data))}
print(request_headers)
response = requests.post(url,headers=request_headers,data=bulk_data)
print (response) # Response 200 : Validated data / Response 429 : Too many request, please wait
print("_________________________________________")
print()
time.sleep(15)
My JSON file :
{
"GPS": {
"latitude": 48.75607,
"longitude": 2.30202,
"speed": 10.04384
},
"GROVE": [
{
"Compas": {
"x": 2.583,
"y": -4.439,
"z": 0.435
}
},
{
"Gyroscope": {
"x": 2.56433,
"y": -4.45352,
"z": 0.47237
}
},
{
"Acceleration": {
"x": 0.28,
"y": 0.01,
"z": 0.93
}
},
{
"degNord": 20.743
}
],
"GIROUETTE": {
"degVent": 30.46389
}
}

Why this kind of problem is showing everytime?
Below is my code which I wish can change the color for the visualization without refresh the page.
% Set your ThingSpeak channel and API keys
channelID = 2044216;
readAPIKey = '4SVDGTR02R02PFAD';
% Initialize variables
threshold = 0;
circleRadius = 6;
circleCenterX = 30;
circleCenterY = 40;
greenColor = [0 1 0];
redColor = [1 0 0];
% Create the circle visualization
figure('Position',[100 100 200 200]);
circle = rectangle('Position',[circleCenterX - circleRadius, circleCenterY - circleRadius, circleRadius*2, circleRadius*2],...
'Curvature',[1,1],'FaceColor',greenColor);
axis square;
axis off;
% Continuously update the circle color based on the ThingSpeak channel data
while true
% Read the latest value of field 2 from your ThingSpeak channel
fieldData = thingSpeakRead(channelID, 'ReadKey', readAPIKey, 'Fields', 2, 'NumPoints', 1);
% Update the circle color based on the value of field 2
if fieldData == threshold
circle.FaceColor = redColor;
else
circle.FaceColor = greenColor;
end
end
Hi, I am currently doing a parking system that able to show red colour when the parking space is filled and change to green colour when the parking space is empty. I am using Matlab visualizations because I need the same indicator to show both two colours.
I am currently facing a problem to let the visualization change colour according to my input. Figure below show the visualization and the chart. I want the visualization able to change between green and red colour with 1 and 0 value from the chart. May I know how could I done this? Thank you.

The code for the visualization are shown below:
radius = 6;
centerX = 30;
centerY = 40;
myColor=[1 0 0];
rectangle('Position',[centerX - radius, centerY - radius, radius*2, radius*2],...
'Curvature',[1,1],'FaceColor',myColor);
axis square;
axis off;
Currently the lamp indicator in my channel can only respond to one condition. How to let the lamp indicator respond to multiple conditions for example the lamp shows red colour when condition is 1 and the same lamp shows green colour when condition is 0?
Hello,
I want to fetch Data from the openweather API.
I want to fetch the value "day" from the API for every hour (Time Control)
But there is a Problem with indexing. I tried also "{ }" but there is also the same Error:
Dot indexing is not supported for variables of this type. Error in Wettervorhersage von openweather (line 10) temperature_Morgen = temperature.temp.day;
Does anyone have a good solution for indexing?
Code
api_url = 'https://api.openweathermap.org/data/2.5/onecall?lat=XXXX&lon=XXXXX&exclude=alerts&appid=XXXXXXXXXXXXXXX&lang=de&units=metric';
options = weboptions('ContentType','json');
%% Daten von der API abrufen
weather_data = webread(api_url,options);
% Werte für die Felder des ThingSpeak-Channels auswählen
temperature = weather_data.daily(1);
temperature_Morgen = temperature.temp.day;
humidity = weather_data.daily(1);
humidity_Morgen = humidity.humidity;
uvindex = weather_data.daily(1);
uvindex_Morgen = uvindex.uvi;
%Dieser Code berechnet die Summe von drei möglicherweise vorhandenen Regenwerten, die im Abschnitt daily{1}, daily{2} und daily{3} eines Wetterdaten-Structs enthalten sein können.
%Jeder Regenwert wird durch Überprüfung der Existenz des Felds 'rain' im jeweiligen Abschnitt geprüft. Wenn das Feld existiert, wird der Regenwert gespeichert. Andernfalls wird ein Nullwert verwendet.
%Die gespeicherten Regenwerte werden schließlich addiert und in der Variable "rain" gespeichert.
rain = 0;
for i = 1:3
if isfield(weather_data.daily(i),'rain')
rain_Next = weather_data.daily(i);
rain_Next = rain_Next.rain;
rain = rain + rain_Next;
end
end
% Daten an ThingSpeak senden
writeChannelID = XXXXXXXX; % ID des ThingSpeak-Channels
writeAPIKey = 'XXXXXXXXXXX'; % API-Schlüssel des ThingSpeak-Channels
thingSpeakWrite(writeChannelID, [temperature_Morgen, humidity_Morgen, rain, uvindex_Morgen], 'WriteKey', writeAPIKey);
Openweather json
{
{current}
{today}
{daily[{temp{day}}
{temp{day}}
{temp{day}}
{temp{day}}
{temp{day}}
]
}}
Error:
Dot indexing is not supported for variables of this type. Error in Wettervorhersage von openweather (line 10) temperature_Morgen = temperature.temp.day;
i dont send values tu my channel. my log is this
thanks all
Gretings
juan
log.
Fri Mar 3 22:37:20 2023 user.notice root: [IoT.MQTT]:MQTT Publish Case: 1
Fri Mar 3 22:37:20 2023 user.notice root: [IoT.MQTT]:MQTT Publish Parameters
Fri Mar 3 22:37:20 2023 user.notice iot_keep_alive: Internet Access OK: via wlan0-2
Fri Mar 3 22:37:20 2023 user.notice root: [IoT.MQTT]:server[-h]: mqtt3.thingspeak.com
Fri Mar 3 22:37:20 2023 user.notice root: [IoT.MQTT]:port[-p]: 1883
Fri Mar 3 22:37:20 2023 user.notice iot_keep_alive: use WAN or WiFi for internet access now
Fri Mar 3 22:37:20 2023 user.notice root: [IoT.MQTT]:user[-u]: mwa0000029370786
Fri Mar 3 22:37:20 2023 user.notice root: [IoT.MQTT]:pass[-P]: CCHFW9ZV7F0LDW7C
Fri Mar 3 22:37:20 2023 user.notice root: [IoT.MQTT]:pub_qos[-q]: 0
Fri Mar 3 22:37:20 2023 user.notice root: [IoT.MQTT]:cafile[--cafile]:
Fri Mar 3 22:37:20 2023 user.notice root: [IoT.MQTT]:cert[--cert]: /etc/iot/cert/
Fri Mar 3 22:37:20 2023 user.notice root: [IoT.MQTT]:key[--key]: /etc/iot/cert/
Fri Mar 3 22:37:20 2023 user.notice root: [IoT.MQTT]:clientID[-i]: dragino-1fb960
Fri Mar 3 22:37:20 2023 user.notice root: [IoT.MQTT]:remote_id: 2052257
Fri Mar 3 22:37:20 2023 user.notice root: [IoT.MQTT]:pub_topic[-t]: channels/2052257/publish/X7B8RVY2VP7XERPJ
Fri Mar 3 22:37:20 2023 user.notice root: [IoT.MQTT]:decoder: Not Set
Fri Mar 3 22:37:20 2023 user.notice root: [IoT.MQTT]:mqtt_data[-m]: field1=87&status=MQTTPUBLISH
Hello, I am trying to display my Charts in a React Native App but I can't figure out what is the URL that I should use to display it. Any ideas?
Salve, ho appena realizzato la stazione meteo con l'esp8266 ma non riesco a capire come impostare l'ora di roma (it) sul display. Qualcuno può aiutarmi? Grazie.

I want to fit a circle just like the black line drawn in the figure and trying to find its radius. below is the code i am writing but not getting anything significant. kindly help me how to approch this kind of problems
%%---------------------------- matlab code -----------------------------------%%
clear all
clc
% read the image
img = imread('gra.png');
% convert the image to grayscale
img_gray = rgb2gray(img);
% perform edge detection using the Canny algorithm
edge_img = edge(img_gray, 'sobel');
% perform hough transform to detect circles
[centers, radii] = imfindcircles(edge_img, [10 50000],'ObjectPolarity','bright','Sensitivity', 0.95);
% find the largest circle
[max_r, max_i] = max(radii);
max_center = centers(max_i, :);
% plot the results
figure;
imshow(img);
hold on;
viscircles(max_center, max_r, 'EdgeColor', 'b');
Hi,
I'm trying to communicate with my channel ohowever it looks like I'm missing something as my data doesn't appear in the feeds. Below is my code:
#define SW_VERSION " ThinkSpeak.com" // SW version will appears at innitial LCD Display
#define TINY_GSM_MODEM_SIM900
#include <TinyGsmClient.h>
#define SerialAT Serial
TinyGsm modem(SerialAT);
TinyGsmClient client(modem);
/* ESP12-E & Thinkspeak*/
const char apn[] = "xxxxx";
const char user[] = "";
const char pass[] = "";
const char server[] = "api.thingspeak.com";
const int port = 80;
const char* TS_SERVER = "api.thingspeak.com";
String TS_API_KEY ="xxxxx";
int sent = 0;
/* TIMER */
#include <SimpleTimer.h>
SimpleTimer timer;
/* OLED */
#include <ACROBOTIC_SSD1306.h> // library for OLED: SCL ==> D1; SDA ==> D2
#include <SPI.h>
#include <Wire.h>
/* DHT22*/
#include "DHT.h"
#define DHTPIN D3
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
float hum = 0;
float temp = 0;
/* Soil Moister */
#define soilMoisterPin A0
#define soilMoisterVcc D4 //not used. LM393 VCC connect to 3.3V
int soilMoister = 0;
/* DS18B20 Temperature Sensor */
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 14 // DS18B20 on NodeMCU pin D5 corresponds to GPIO 014 on Arduino
float soilTemp;
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
void setup()
{
Serial.begin(115200);
delay(10);
Serial.println(".... Starting Setup");
SerialAT.begin(115200);
delay(3000);
// Restart takes quite some time
// To skip it, call init() instead of restart()
Serial.println("Initializing modem...");
modem.init();
pinMode(soilMoisterVcc, OUTPUT);
Serial.begin(115200);
delay(10);
oledStart();
dht.begin();
DS18B20.begin();
timer.setInterval(2000L, getDhtData);
timer.setInterval(7000L, getSoilMoisterData);
timer.setInterval(9000L, getSoilTempData);
timer.setInterval(19000L, sendDataTS);
digitalWrite (soilMoisterVcc, LOW);
}
void loop()
{
displayData();
timer.run(); // Initiates SimpleTimer
}
/***************************************************
* Start OLED
**************************************************/
void oledStart(void)
{
Wire.begin();
oled.init(); // Initialze SSD1306 OLED display
clearOledDisplay();
oled.clearDisplay(); // Clear screen
oled.setTextXY(0,0);
oled.putString(" ");
}
/***************************************************
* Get DHT data
**************************************************/
void getDhtData(void)
{
float tempIni = temp;
float humIni = hum;
temp = dht.readTemperature();
hum = dht.readHumidity();
if (isnan(hum) || isnan(temp)) // Check if any reads failed and exit early (to try again).
{
Serial.println("Failed to read from DHT sensor!");
temp = tempIni;
hum = humIni;
return;
}
}
/***************************************************
* Get Soil Moister Sensor data
**************************************************/
void getSoilMoisterData(void)
{
soilMoister = 0;
digitalWrite (soilMoisterVcc, HIGH);
delay (500);
int N = 3;
for(int i = 0; i < N; i++) // read sensor "N" times and get the average
{
soilMoister += analogRead(soilMoisterPin);
delay(150);
}
digitalWrite (soilMoisterVcc, LOW);
soilMoister = soilMoister/N;
Serial.println(soilMoister);
soilMoister = map(soilMoister, 689, 274, 0, 100);
}
/***************************************************
* Get SoilTemp sensor data
**************************************************/
void getSoilTempData()
{
DS18B20.requestTemperatures();
soilTemp = DS18B20.getTempCByIndex(0);
int newData = ((soilTemp + 0.05) * 10); //fix soilTemp value to 1 decimal place.
soilTemp = (newData / 10.0);
}
/***************************************************
* Display data at Serial Monitora & OLED Display
**************************************************/
void displayData(void)
{
Serial.print(" Temperature: ");
Serial.print(temp);
Serial.print("oC Humidity: ");
Serial.print(hum);
Serial.println("%");
Serial.print("SoilTemp: ");
Serial.print(soilTemp);
Serial.print("oC");
oled.setTextXY(1,0); // Set cursor position, start of line 2
oled.putString("TEMP: " + String(temp) + " oC");
oled.setTextXY(3,0); // Set cursor position, start of line 2
oled.putString("HUM : " + String(hum) + " %");
oled.setTextXY(5,0); // Set cursor position, start of line 2
oled.putString("Tsoil:" + String(soilTemp) + " oC");
oled.setTextXY(7,0); // Set cursor position, start of line 2
oled.putString("Hsoil: " + String(soilMoister) + " %");
}
/***************************************************
* Clear OLED Display
**************************************************/
void clearOledDisplay()
{
oled.setFont(font8x8);
oled.setTextXY(0,0); oled.putString(" ");
oled.setTextXY(1,0); oled.putString(" ");
oled.setTextXY(2,0); oled.putString(" ");
oled.setTextXY(3,0); oled.putString(" ");
oled.setTextXY(4,0); oled.putString(" ");
oled.setTextXY(5,0); oled.putString(" ");
oled.setTextXY(6,0); oled.putString(" ");
oled.setTextXY(7,0); oled.putString(" ");
oled.setTextXY(0,0); oled.putString(" ");
}
/***************************************************
* Sending Data to Thinkspeak Channel
**************************************************/
void sendDataTS(void)
{
if (client.connect(TS_SERVER, 80))
{
String postStr = TS_API_KEY;
postStr += "&field1=";
postStr += String(temp);
postStr += "&field2=";
postStr += String(hum);
postStr += "&field3=";
postStr += String(soilMoister);
postStr += "&field4=";
postStr += String(soilTemp);
postStr += "\r\n\r\n";
client.print("POST /update HTTP/1.1\n");
client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY: " + TS_API_KEY + "\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(postStr.length());
client.print("\n\n");
client.print(postStr);
delay(1000);
}
sent++;
client.stop();
}
First I get this on my serial monitor:

After some time:

And after some more time:

With my limited knowledge on the subject I can't figure it out.
Any help would be appreciated.
Thanks.
Not able to display password by copying to clipboard or by clicking the unhide icon - have tried multiple computers.
Anyone else had this problem with mqtt?
