7:50 am

February 14, 2019

Hi,
I'm working on a project that requires me to send sensor readings to Blynk and ThingSpeak over Bluetooth. I am able to send the readings to Blynk and using Blynks webhook widget I am trying to send the data to my ThingSpeak channel.
I haven't been able to get the data displayed on the graphs, even though the number of entries increases. The graphs I have sent up are displaying straight lines at 0. I'm wondering if it is possible to send the sensor data to ThingSpeak by using the webhook widget.
I don't have any sort of WiFi module in this project, all I am working with is the DHT22 sensor, an Arduino Uno and an Open-Smart Bluetooth module.
4:13 pm


Moderators
March 7, 2017

Using bluetooth to update ThingSpeak sounds like an interesting project. Can you tell us more about your project?
It is possible that you are sending extra characters in your data that ThingSpeak is interpreting as strings, or the data is not going into the field you expect it is.
Try looking at the export recent data button on your channel view.
You can post the data here is if is not clear why it is not plotting, or you can share your channel number if it is public and I will have a look.
7:29 am

February 14, 2019

I have written code that will send the sensor data to Blynk over Bluetooth. Using a webhook widget in Blynk I am trying to send the data to ThingSpeak.
In the Blynk webhook I have the URL: http://api.thingspeak.com/update?api_key=XXXXXXX&field1=t&field2=h&field3=ldr
I have noticed that if I put field1= 20, the value will be updated on the graph.
This is the code I have:
```
#define BLYNK_PRINT Serial
#include
#include
#include
#include
#include
// Auth Token recieved in the Blynk App.
char auth[] = "7c5d501236d44df3838c01cffc2f086e";
char thingspeak = "1CO81IDJXVZVGRDV" ;
// create ble serial instance
SoftwareSerial SerialBLE(10, 11); // Rx, Tx
#define DHTPIN 13 // Pin DHT22 is connected to
#define ldrPIN A0 // Pin LDR is connected to
#define DHTTYPE DHT22 // DHT 22
float t;
float h;
float ldr;
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
void setup()
{
// Debug console
Serial.begin(9600);
SerialBLE.begin(9600);
Blynk.begin(SerialBLE, auth);
Serial.println("Waiting for connections...");
dht.begin();
// Setup a function to be called every 5 second
timer.setInterval(10000, sendSensor);
timer.setInterval(10000, sendLDR);
timer.setInterval(30000, SendtoThingspeak);
}
void loop()
{
Blynk.run();
timer.run();
}
void sendSensor()
{
float h = dht.readHumidity();
// String hString = String(h);
float t = dht.readTemperature();
// String tString = String(t);
// Write DHT22 values to Blynk
Blynk.virtualWrite(V4, h);
Blynk.virtualWrite(V5, t);
}
void sendLDR()
{
float ldr = analogRead(ldr);
// Write LDR values to Blynkd
Blynk.virtualWrite(V6, ldr);
}
void SendtoThingspeak()
{
Blynk.virtualWrite(V3, t, h, ldr);
}
```
Sorry if the code is difficult to follow, I don't know how to format it on here. I've been using trial and error for a while now trying to figure it out and am out of ideas as to how to get it working.
5:39 pm


Moderators
March 7, 2017

Formatting code can be rough here.
Is it possible that blynk does not know you are inserting a variable into your webhook url?
http://api.thingspeak.com/update?api_key=XXXXXXX&field1=t&field2=h&field3=ldr
If you scroll down about 1000 pages in their doc
https://docs.blynk.cc/
(I searched 'webhooks") They mention you can escape pin values.
It looks like you can assign a pin value to the webhooks widget, and they talk about using an array to send multiple values.
Let us know if you get it working. I might try Blynk out myself now...
7:24 am

February 14, 2019

I have tried changing the URL to http://api.thingspeak.com/update?api_key=XXXXXXX&field1=/pin%5B0%5D/&field2=/pin%5B1%5D/&field3/pin%5B2%5D/
I'm still getting 0 as the output.
I looked at the document and I don't fully understand how to put the data as an array. I added this to my code:
BLYNK_WRITE(V0){
String webhookdata = param.asStr();
}
But I had no luck.
I have noticed that if I put field1 = 50, 50 will be displayed on the graph. So I think this means that the Bluetooth link between Blynk and Thingspeak works, and I just need to figure out how to get real-time sensor readings to sent and displayed on Thingspeak.
This is my channel id: 639757, I have made it public if you don't mind having a look at it and seeing if I've it sent up correctly.
8:08 am

February 14, 2019

9:08 am


Moderators
March 7, 2017

I noticed that you are trying to write multiple fields. If you try to do this too frequently, ThingSpeak may reject some data. If you do an update to multiple fields in the same post, you will be way less likely to hit the limit. That is why I suggested using the array. Just something to watch out for.
When I went to your channel page, the x-axis seems to be in time not date.
You can edit the number of results or number of days using the pencil icon, but if you want more direct control of the x-axis, I suggest using a MATLAB visualization to make a custom plot.
https://www.mathworks.com/help/thingspeak/Plot-Temperature-and-Wind-Speed-on-Two-Different-Axes.html
You can also use the charts control to specify a specific date range with start and end.
https://www.mathworks.com/help/thingspeak/createchart.html
Most Users Ever Online: 166
Currently Online:
11 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
rw950431: 272
Vinod: 240
piajola: 95
turgo: 70
vespapierre: 63
Adarsh_Murthy: 62
Member Stats:
Guest Posters: 1
Members: 8665
Moderators: 1
Admins: 2
Forum Stats:
Groups: 3
Forums: 14
Topics: 1600
Posts: 5760
Newest Members:
Zain-Ul-Abidin, wellbeingcentresuk, Vamsi, frankmehlhop, bhumin, dennysrodialahModerators: cstapels: 460
Administrators: Hans: 405, lee: 457