I use a sensor to measure the temperature. This is returned as float. I feed this float using typecasting (int) to a blink function. This works fine.
But the next is step is using this same unchanged integer in a struct and send it over 433MHz using RadioHead.
Here the integer is no longer an integer and it never gets sent.
When I hard code the sensor measurement value, it works. When I hard code the value in the struct it works. When I hard code the value anywhere it works.
My assumption is: when the blink works it must be an integer. When sending a hard coded integer works it must also send the measured value confirmed to be an integer. What am I missing here?
The chip is an ATtiny85
The sensor is a DS18B20
TinyHead, my light RadioHead version: https://gitlab.com/thijsvanulden/TinyHead
This is the Logic Analyzer view of what happens measured on the Data pin of the 433MHz transmitter. So something is happening at least. I can't find an Analyzer 'plugin' to translate the message coded in RadioHead, it's not Manchester encoding as it seems.
Memory Usage -> http://bit.ly/pio-memory-usage
DATA: [======== ] 75.8% (used 388 bytes from 512 bytes)
PROGRAM: [========= ] 86.4% (used 7080 bytes from 8192 bytes)
#include <Arduino.h>
#include <util/delay.h>
#include <OneWire.h>
#include <RH_ASK.h>
#include <DallasTemperature.h>
#define TICKLE_ID 0
#define ONE_WIRE_BUS 2
#define RADIOHEAD_BAUD 2000
#define RADIOHEAD_TX_PIN 1
#define RADIOHEAD_RX_PIN -1
#define LEDPIN 0
struct tickle {
uint16_t id = TICKLE_ID;
uint16_t value1;
uint16_t value2;
};
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
RH_ASK driver(RADIOHEAD_BAUD, RADIOHEAD_RX_PIN, RADIOHEAD_TX_PIN);
void blink(int repeat) {
for (int i = 0; i < repeat; i++) {
digitalWrite(LEDPIN, HIGH);
_delay_ms(100);
digitalWrite(LEDPIN, LOW);
_delay_ms(100);
}
}
void senddata(float temperatuur) {
blink((int) temperatuur); // this always works
struct tickle package; // make a Tickle package
package.id = TICKLE_ID; // hard-coded device ID
package.value1 = 0; // any positive int up to 2^16
package.value2 = temperatuur * 100; // any positive int up to 2^16
driver.send((uint8_t *)&package, sizeof(package));
driver.waitPacketSent(); // wait for it ~Barney
}
void setup() {
pinMode(LEDPIN, OUTPUT);
digitalWrite(LEDPIN, HIGH);
sensors.begin();
driver.init();
_delay_ms(100);
digitalWrite(LEDPIN, LOW);
}
void loop() {
sensors.requestTemperatures();
_delay_ms(100);
senddata(sensors.getTempCByIndex(0)); // hard coded 17.07 works
_delay_ms(10000);
}

getTempCByIndexis used, but send a constant. In the functionsenddata: convert it:uint16_t t = temperature;get rid of it:t /= 10000;add a constant:t += 1789;fill the package:package.value2 = t;. Linking thegetTempCByIndexfunction into the binary might be too much for the ram usage.