now if i use this code i see on my receiver actually data, example
25
25
26
26
26
and etc.
it okay, but i want use next format for transfered
{"id":"11","t":"value"}
please help me, how i can send this string with temperature value?
edit on my receiver side i can't because i want use id for my temperature sensor
or, since 'id' will be a variable (of sorts, different for each transmitter*): sprintf(msg, "{\"id\":\"%d\",\"t\":\"%d\"}", id,Temp);
*you can then define the 'id' at the top of your file to be changed easily when you program each one.
If your transmitters are battery-powered you could do with shortening these messages, to save power. You don't really need the captions, the receiver should know what the data looks like. sprintf(msg, "%02d %03d", id,Temp);
will always output the ids in 2 digits (e.g. "02") and the temps in 3 (e.g. "030" or "-23").
hi, Paul'S and quilkin, thank you for your reply
yes, i think ... i will be use define for at, it really comfortable
i think...maybe i change my string to the next format: 0122 when 01 - this is id, 22 this is temperature
hi guys, can you help me again...now i want use library jeelib for sleep, and it work but if i want control pwr for transmitter i can't pwr down for pin:( see my code for example
#define pwr 4
OneWire ds(0);
const bool LOWPOWER = true; // set to true to enable low-power sleeping
// must be defined in case we're using the watchdog for low-power waiting
ISR(WDT_vect) { Sleepy::watchdogEvent(); }
void setup () {
pinMode(pwr, OUTPUT);
vw_set_ptt_inverted(true);
vw_set_tx_pin(1);
vw_setup(2000);
}
void loop () {
digitalWrite(pwr, HIGH);
byte data[2];
ds.reset();
ds.write(0xCC);
ds.write(0x44);
ds.reset();
ds.write(0xCC);
ds.write(0xBE);
data[0] = ds.read();
data[1] = ds.read();
int Temp = (data[1]<< 8)+data[0];
Temp = Temp>>4;
char msg[255];
dtostrf(Temp, 0, 0, msg);
vw_send((uint8_t *)msg, strlen(msg)); // Send temperature.
vw_wait_tx();
//now need pwr LOW but if i add LOWthen sleep not work
for (byte i = 0; i < 1; ++i)
Sleepy::loseSomeTime(10000);//sleep on the 10 sec
}
how correctly control pwr, HIGH or LOW for transmitter and dallas? because now it not work:(
Why on earth are you using dtostrf (double to formatted string) to convert an int to a string? Do you REALLY think that you need a 255 character buffer to hold an int (whose upper limit is 32767) as a string?
What's with the piss-poor indenting of your code. Use Tools + Auto Format before you post code again.
because now it not work:(
We can't help you with that, because you've provided no schematic, no links to non-standard libraries, and no clue what you actually see happening.
hi,
it buffer for example and i can use msg[32] but it not solve my problem
i use this libraries GitHub - jeelabs/jeelib: JeeLib for Arduino IDE: Ports, RF12, and RF69 drivers from JeeLabs and VirtualWire Library, for very cheap wireless communication GitHub - PaulStoffregen/OneWire: Library for Dallas/Maxim 1-Wire Chips
i'm sorry i don't tell you...this example i use on the the attiny85 and it work...i mean sleep work and i can transmit data but if i use digitalWrite(pwr, HIGH); for enable pwr pin and digtalWrite(pwr, LOW); for disable digital pun it not work
my scheme:
pin 0 for ds18b20
pin 1 for transmitter
pin 4 for pwr ds18 and transmitter( i trying use 3 and 4 pin for power but not have success result)
i use jeelib library for wdt, i want use next logic: check temperature -> enable pwr pin -> send data -> disable pwr pin -> sleep on the one minutes then again
thank you
yes, not worked pwr pin enable and disable pwr pin:( but if i delete digitalWrite(pwr, x) i see success transfer data via rf. i don't know why:( maybe you have any idea?
guys, help please
how use wdt with low power on the more then 8 second?? one minutes or more...jeelib work if i not use pwr pin, but if i use HIGH lvl or LOW lvl for pwr pin my device not work