@andriej
Hi, I had problem using the main branch mysensors/Raspberry, that because of the bit-field struct (header_s) in Sensor.h They will get packed in different order on the arduino compared to the RPi (at least with my compiler, gcc). In order to fix this I created the 1.4dev branch. It uses full bytes instead of the bit-fields, but you need (of cause) to compile both the sensors (arduino) and the gateway (RPi) using the 1.4dev branch.
We need to fix this in the main branch later on (and use the same files as in mysensors/Arduino/libraries/MySensors)
@ZenBlizzard in case you are measuring the output with a multimeter, you will get an averaged level, since AC current waveform should be sinusoidal and overlapped with the Vcc/2->2.56V in your case.
To measure the current you need a decently high sampling and some math.
#define SENSITIVITY 66 // mV/A
const float readings = 5;
const float alpha = 2.0 / (2 * readings + 1);
for (ifor = 0; ifor < 250; ifor++)
{
// Voltage
voltageSampleRead = analogRead(V) * vccRead / 1023 - vccRead / 2; /* read the sample value including offset value*/
voltageSampleSum = voltageSampleSum + sq(voltageSampleRead); /* accumulate total analog values for each sample readings*/
voltageSampleOffsetSum = voltageSampleOffsetSum + voltageSampleRead;
// Current
currentSampleRead = analogRead(I) * vccRead / 1023 - vccRead / 2; /* read the sample value including offset value*/
currentSampleSum = currentSampleSum + currentSampleRead * currentSampleRead; /* accumulate total analog values for each sample readings*/
currentSampleOffsetSum = currentSampleOffsetSum + currentSampleRead;
wait(1);
}
voltageMean = voltageSampleSum / ifor; /* calculate average value of all sample readings taken*/
voltageOffset = voltageSampleOffsetSum / ifor;
reading = (sqrt(voltageMean) - voltageOffset) * 230.0 / 1.0; // read voltage / reported voltage.
voltage = round_to_dp(alpha * reading + (1 - alpha) * voltage,1);
Serial.println(voltage);
if (voltage < 25) voltage = 0;
currentMean = currentSampleSum / ifor; /* calculate average value of all sample readings taken*/
currentOffset = currentSampleOffsetSum / ifor;
reading = (sqrt(currentMean) - currentOffset) / SENSITIVITY * 1000 - currentZeroOffset; // subtract no load current.
if (reading < 0) reading = 0;
current = round_to_dp( alpha * reading + (1 - alpha) * current,2);
It seems you can access the child ID from the sent message by looking at the destination property. If you have the message object, you can extract the ID directly from there.
Hi, I'm glad CodeGarage is taking over! Please are there any updates since January what's happening? The GitHub repo hasn't gotten commits for over a year. Thanks!
When connecting an accelerometer to your PC, consider its communication protocol (I2C or SPI) and the appropriate interface device, like a microcontroller (e.g., Arduino). You may also need additional hardware for voltage adjustment or signal conditioning, depending on the sensor’s specifications.