Arduino UNO WiFi Dev with HX711 load cell send data to ThingSpeak | Arduino | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





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

sp_Feed sp_TopicIcon
Arduino UNO WiFi Dev with HX711 load cell send data to ThingSpeak
No permission to create posts
March 6, 2017
11:17 am
Avatar
s161025
New Member
Members
Forum Posts: 3
Member Since:
March 6, 2017
sp_UserOfflineSmall Offline

Hello, everyone!

I am not a programmer as you will realise, but I set up a program for measuring weight with HX711 load cell for a uni project, and I would like to upload the measurments to my TS channel. The arduino UNO WiFi Dev board is connected to a WiFi network but I can't manage to make it work.

Before Setup, I defined the weight (3 decimals) and led (reading from A1)

#define CONNECTOR "rest"
#define SERVER_ADDR "api.thingspeak.com"

#define APIKEY_THINGSPEAK " " //Insert your API Key

float weight = 0.000;

int led;

and in Loop

weight = scale.get_units();
pump = analogRead(A1);

String uri = "/update?api_key=";
uri += APIKEY_THINGSPEAK;
uri += "&field1=";
uri += String(weight);
uri += "&field2=";
uri += String(led);

Ciao.println("Send data on ThingSpeak Channel");

CiaoData data = Ciao.write(CONNECTOR, SERVER_ADDR, uri);

if (!data.isEmpty()) {
Ciao.println( "State: " + String (data.get(1)) );
Ciao.println( "Response: " + String (data.get(2)) );
}
//delay(30000); // Thinkspeak policy
else {
Ciao.println("Write Error");
}

The delay is commented because I use different time-step code.

The thing is that I can Serial.print the values of weight and led but not to upload them. However, when I give specific values to them it uploads without problem. Any help would be much appreciated.

March 7, 2017
11:07 am
Avatar
JasonW

MathWorks
Members
Forum Posts: 28
Member Since:
October 21, 2016
sp_UserOfflineSmall Offline

It looks like you are declaring an int led in the first part.  But then in the looped code, you use a variable called pump to read the analog input.

Then further down you use  uri += String(led);

Since led hasn't been assigned a value, adding it to the uri string will have unexpected results. 

Try this:

change int led to int pump

change uri += String(led); to uri += String(pump); 

March 7, 2017
5:26 pm
Avatar
s161025
New Member
Members
Forum Posts: 3
Member Since:
March 6, 2017
sp_UserOfflineSmall Offline

My bad. I meant led = AnalogRead(A1);

This seems consistant. I think that the problem is somewhere else.

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
18 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 261

Vinod: 196

piajola: 85

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

Newest Members:

MiguelWap, JamesdinnA, ScottTug, ThomasApesy, RicardoVeque, AlbertRop

Administrators: Hans: 387, lee: 457