Hello,
i have an arduino nano with a network shield.
when i compile the program, i get a warning about stability .
but that is not the problem i think.
my program, setup the network card, read the one wire temperature sensor and output it to a server.
the first sensor is read good, but the second sensor is always 0.
i know it is connected good, because when i load one of the examples sketches for the dallas temp sensor it shows, 2 sensors and displays the correct values.
What could be wrong, please need some help on how to find out what is wrong.
// Demo using DHCP and DNS to perform a web client request.
// 2011-06-08 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php
#include <EtherCard.h>
#include <OneWire.h>
#include <DallasTemperature.h>
char payload[90];
void(* resetFunc) (void) = 0; //declare reset function @ address 0
// ethernet interface mac address, must be unique on the LAN
// and other stuff used for the network interface
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
byte Ethernet::buffer[700];
char website[] PROGMEM = "82.72.232.147";//destination website
// Stuff used for one wire sensors
// Data wire is plugged into pin 7 on the Arduino
#define ONE_WIRE_BUS 7
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
// Some random stuff used in this program
static uint32_t timer;
byte wd_counter;
// called when the client request is complete
static void my_callback (byte status, word off, word len) {
Ethernet::buffer[off+300] = 0;
// get_reply_data gets the data part of the reply and puts it in the line_buf char a
// Controleer of de data juist is ontvangen.
if (strcmp((const char*) Ethernet::buffer,"HTTP/1.1 200 OK"))
{
wd_counter=0;
Serial.println(" recieved ok.");
} else
{
Serial.println(" !!! ERROR !!!.");
Serial.println(">>>");
Serial.print((const char*) Ethernet::buffer+off);
Serial.println("<<<");
}
}
//Setup the board
void setup () {
//Start serial port
Serial.begin(9600);
Serial.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
Serial.println("\nNANO EMONCMS Temperatuur sender\n\n\n");
//Start ethernet port
if (ether.begin(sizeof Ethernet::buffer, mymac,10) == 0)
Serial.println( "Failed to access Ethernet controller");
//Get own ip adress
if (!ether.dhcpSetup())
Serial.println("DHCP failed");
ether.printIp("IP: ", ether.myip);
ether.printIp("GW: ", ether.gwip);
ether.printIp("DNS: ", ether.dnsip);
//Look ip destination website
if (!ether.dnsLookup(website))
Serial.println("DNS failed");
ether.printIp("SRV: ", ether.hisip);
// Startup one wire sensors
sensors.begin();
}
// Main program
void loop () {
ether.packetLoop(ether.packetReceive());
if (wd_counter>=10) {
Serial.println("Resetting device");
resetFunc();
}
if (millis() > timer) {
wd_counter++;
timer = millis() + 25000;
Serial.println(" ");
Serial.print("Attempt number ");
Serial.print(wd_counter);
Serial.print(" of 10, data send to emoncms: ");
sensors.requestTemperatures();
sprintf(payload,"{Temp_buiten_camping:%d,Temp_binnen_camping:%d}",round(sensors.getTempCByIndex(1)*10),round(sensors.getTempCByIndex(0)*10));
Serial.print(payload);
ether.browseUrl(PSTR("/emoncms/input/post.json?apikey=913f557706d069745bfe8dac70040261&json="), payload, website, my_callback);
}
}
and of course the output from arduino.
Sketch uses 17.258 bytes (56%) of program storage space. Maximum is 30.720 bytes.
Global variables use 1.565 bytes (76%) of dynamic memory, leaving 483 bytes for local variables. Maximum is 2.048 bytes.
Weinig geheugen beschikbaar, er kunnen zich stabiliteitsproblemen voordoen