Arduino UNO WiFi Dev with HX711 load cell send data to ThingSpeak | 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
Arduino UNO WiFi Dev with HX711 load cell send data to ThingSpeak
Avatar
s161025
New Member
Forum Posts: 3
sp_UserOfflineSmall Offline
1
March 6, 2017 - 11:17 am
sp_Permalink sp_Print

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.

Avatar
JasonW

Forum Posts: 23
sp_UserOfflineSmall Offline
2
March 7, 2017 - 11:07 am
sp_Permalink sp_Print

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); 

Avatar
s161025
New Member
Forum Posts: 3
sp_UserOfflineSmall Offline
3
March 7, 2017 - 5:26 pm
sp_Permalink sp_Print

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:
28 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:

candacele1

WilliamBer

roxieob18

Metawatch

ozayagw

ubabeutiti

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

 

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee