Problem using Thingspeak Library with local Thingspeak installation | Arduino | Forum

Avatar

Please consider registering
Guest

Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

Register Lost password?
sp_Feed sp_TopicIcon
Problem using Thingspeak Library with local Thingspeak installation
Avatar
Coolio11

Silver
Forum Posts: 6
sp_UserOfflineSmall Offline
1
April 6, 2016 - 5:25 pm
sp_Permalink sp_Print

I just installed Thingspeak locally on a Raspberry Pi. The server seems to be working well, and I can successfully update my channels using python scripts.

But when using the official Thingspeak library for Arduino, I am unable to make a connection to the local server. Previously I had been using the library successfully for updating data to api.thingspeak.com.

I've tried using: ThingSpeak.begin(client,"192.168.0.178", 3000);, which contains the correct URL and port number of my local installation, but that doesn't work.

I've tried modifying the library .h file and replacing "api.thingspeak.com" with my URL, and the port 80 in the code with my local port number, but that doesn't work either.

Is there a known problem with using the Thingspeak library with a local installation? Is there a way I can get this to work? Alternatively I'll just go back to the older way of doing it, by not using the library.

Thanks!

Avatar
Coolio11

Silver
Forum Posts: 6
sp_UserOfflineSmall Offline
2
April 7, 2016 - 10:11 am
sp_Permalink sp_Print

I tried it like this too: ThingSpeak.begin(client,IPAddress(192,168,0,178), 3000); , but that didn't work either.

Then I enabled debug printing from the library, and this is the result I get (I removed the writeAPIKey):

ts::setField (field: 1 value: "0")
ts::setField (field: 2 value: "0")
ts::setField (field: 3 value: "0")
ts::setField (field: 4 value: "0")
ts::setField (field: 5 value: "0")
ts::setField (field: 6 value: "0")
ts::writeRaw (channelNumber: 3 writeAPIKey: XXXXXXXXXX postMessage: "field1=0&field2=0&field3=0&field4=0&field5=0&field6=0")
Connect to 192.168.0.178...Success.
POST "field1=0&field2=0&field3=0&field4=0&field5=0&field6=0&headers=false"
Result Code: 200

It looks like it's connecting okay, and the result code is "200" which should mean that there are no problems. But no data gets posted to the channel.

I've tried changing to a different channel with a different API key, but still it doesn't work. Everything else is working with my local installation, including reading data from multiple channels, and writing data with python. I just can't get the Arduino to post the data, with the library or without.

Avatar
Coolio11

Silver
Forum Posts: 6
sp_UserOfflineSmall Offline
3
April 7, 2016 - 12:39 pm
sp_Permalink sp_Print

I finally figured it out. It only works if Rails is using Webrick, instead of the default Thin server. If I do "rails server webrick", then I'm able to upload data from the arduino, either from the official library or without the library.

Avatar
jpsabo
New Member
Forum Posts: 4
sp_UserOfflineSmall Offline
4
July 2, 2016 - 3:58 pm
sp_Permalink sp_Print

Thanks for the posting…this is just what I needed to get an Arduino Yun talking to my local ThingSpeak server (ubuntu-14.04.4-server-amd64 on VMWare Fusion 6.0.6):

void setup() {

// pass custom IP address (10.0.1.196) and port number (3000) to ThingSpeak

ThingSpeak.begin(client, IPAddress(10, 0, 1, 196), 3000);              

…other setup code

}

 

Complete test sketch

// Upload random numbers to a local ThingSpeak server.
// ThingSpeak server is running as a virtual machine in VMWare.
// Optimally, assign a static IP address to the virtual machine so that IP address can stay fixed in the sketch.

#include <ThingSpeak.h>

#define myChannelNumber put_ThingSpeak_channel_here
#define myWriteAPIKey "API write key goes inside the quotes"

#include <YunClient.h>
YunClient client;

void setup() {
pinMode(13, OUTPUT); // initialize digital pin 13 as an output

Bridge.begin(); // start Bridge

ThingSpeak.begin(client, IPAddress(10, 0, 1, 196), 3000); // pass custom IP address and port (local VMWare ThingSpeak server) to ThingSpeak
}

void loop() {
float v1, v2, v3, v4;

digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500);
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(500);
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500);
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW

ThingSpeak.setField(1, random(5, 9) * 10.0F / random(5, 9) * 1.0F); // place data into ThingSpeak fields
ThingSpeak.setField(2, random(5, 9) * 10.0F / random(5, 9) * 1.0F);
ThingSpeak.setField(3, random(5, 9) * 10.0F / random(5, 9) * 1.0F);
ThingSpeak.setField(4, random(5, 9) * 10.0F / random(5, 9) * 1.0F);

ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey); // Write the fields all at once to the ThingSpeak server

delay(15000); // delay next write for 15 sec (ThingSpeak minimum update frequency)
}

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online: jacktheripper125, pudderz
18 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 252

Vinod: 164

cstapels: 96

piajola: 75

vespapierre: 63

Adarsh_Murthy: 59

Newest Members:

bbruno22

pudderz

Utkya

Poornak26

LindasHed

reddysiva

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

 

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee