I'm very interested by your setup. It has been a shame to have some low voltage power in order to measure power consumption
I hope you can display something soon.
Regards,
Just to let you know that I solved the issue.
I found a library where you can control the speed and make sure it get to it's position.
You can find it here: https://github.com/netlabtoolkit/VarSpeedServo
I incorporated it in the Mysensor sketch and it works eventhoug it looks like it only goes like 90 degrees but it's enough for me :
#include <MySensor.h>
#include <SPI.h>
#include <VarSpeedServo.h>
// #include <Servo.h>
#define SERVO_DIGITAL_OUT_PIN 3
#define SERVO_MIN 0 // Fine tune your servos min. 0-180
#define SERVO_MAX 180 // Fine tune your servos max. 0-180
#define DETACH_DELAY 900 // Tune this to let your movement finish before detaching the servo
#define CHILD_ID 10 // Id of the sensor child
MySensor gw;
MyMessage msg(CHILD_ID, V_DIMMER);
VarSpeedServo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
// Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created Sensor gw(9,10);
unsigned long timeOfLastChange = 0;
bool attachedServo = false;
void setup()
{
// Attach method for incoming messages
gw.begin(incomingMessage);
// Send the sketch version information to the gateway and Controller
gw.sendSketchInfo("Servo", "1.0");
// Register all sensors to gw (they will be created as child devices)
gw.present(CHILD_ID, S_COVER);
// Request last servo state at startup
gw.request(CHILD_ID, V_DIMMER);
}
void loop()
{
gw.process();
if (attachedServo && millis() - timeOfLastChange > DETACH_DELAY) {
myservo.detach();
attachedServo = false;
}
}
void incomingMessage(const MyMessage &message) {
myservo.attach(SERVO_DIGITAL_OUT_PIN);
attachedServo = true;
if (message.type==V_DIMMER) { // This could be M_ACK_VARIABLE or M_SET_VARIABLE
int val = message.getInt();
myservo.write(SERVO_MAX + (SERVO_MIN-SERVO_MAX)/100 * val,255,true); // sets the servo position 0-180
// Write some debug info
Serial.print("Servo changed. new state: ");
Serial.println(val);
} else if (message.type==V_UP) {
Serial.println("Servo UP command");
myservo.write(SERVO_MIN,255,true);
gw.send(msg.set(100));
} else if (message.type==V_DOWN) {
Serial.println("Servo DOWN command");
myservo.write(SERVO_MAX,255,true);
gw.send(msg.set(0));
} else if (message.type==V_STOP) {
Serial.println("Servo STOP command");
myservo.detach();
attachedServo = false;
}
timeOfLastChange = millis();
}
Hello,
I want to build this project. But I don't need to power it by batteries. Has anyone the circuit diagram (in FrizIng?)
I have also the problem, that I can't see, on the breadboard picture of this project where the red wire from the battery ends after the connection to the Arduino?
Does it go to the FET and the R7?
Can anyone help me?
I have success!
(oops, that's suppose to be Timer1)
I only sample for 1/60 of a second. What I did was to back up all the timer registered I used and then resorted them after I was done sampling. (As opposed to initializing the registers in setup and then starting the timer when needed.)
Now I have a Nano sampling the data and sending it to a MySensors Gateway on an RPi3B+ which then sends it to an MQTT broker runing on an old laptop. Also running on the laptop is Home Assistant running inside of VirtualBox.
If MySensors does use Timer1, it appears that restoring the registers allows it to be shared.
//------------------------------------------------------ISR
ISR(TIMER1_OVF_vect){ // interrupt service routine for overflow
TCNT1 = TimerPreloadValue; // must be first line! starts the timer counting again
digitalWrite(TRIGGER_START_SAMPLE_PIN,HIGH);
samplesVolts[--sample]=analogRead(VOLTS_IN_PIN); // decrement before capturing
samplesCurrent[sample]=analogRead(CURRENT_IN_PIN);
digitalWrite(TRIGGER_START_SAMPLE_PIN,LOW);
if (!sample){ // count down to zero
digitalWrite(TRIGGER_START_SAMPLE_PERIOD_PIN,LOW); // indicate that sampling is complete
samplingEnd = micros();
TCCR1B &= 248; // turns off timer
}
}
//------------------------------------------------------sampleOneCycle
void sampleOneCycle(){
// back up timer registers
uint8_t TCNT1_b = TCNT1;
uint8_t TCCR1B_b = TCCR1B;
uint8_t TCCR1A_b = TCCR1A;
uint8_t TIMSK1_b = TIMSK1;
// configure timer which starts the sampling
noInterrupts(); // disable all interrupts
TCCR1A = 0;
TCCR1B = 0;
TCNT1 = TimerPreloadValue; // preload timer
//TCCR1B |= (1 << CS10)|(1 << CS12); // 1024 prescaler
TCCR1B &= 248; // turns off timer?
TIMSK1 |= (1 << TOIE1); // enable timer overflow interrupt ISR
// demark sampling
sample = NUMBER_OF_SAMPLES; // count down to zero
digitalWrite(TRIGGER_START_SAMPLE_PERIOD_PIN,HIGH);
samplingStart = micros();
TCNT1 = 65535; // first trigger right away!
TCCR1B |= 1; // turns on timer
interrupts(); // enable all interrupts
// wait for sampling to be complete
while(digitalRead(TRIGGER_START_SAMPLE_PERIOD_PIN)){};
samplingEnd = micros();
// restore timer registers
TCNT1 = TCNT1_b;
TCCR1B = TCCR1B_b;
TCCR1A = TCCR1A_b;
TIMSK1 = TIMSK1_b;
}
@Nca78
Well, for small potted plants, you might have to re-pot the plant. However, the nice benefit that would arise is: no visible sensors, which carries with it very high WAF.
@skywatch @mfalkvidd Thank you for your comments.
I am using Moteino R4 and RFM69 connected to hardware SPI pins. I tried the same pin with softSPI, but I could not get success.
Now I have altered the ADE7763 Arduino library to update SPI settings on every call. And added code to update the only flag on ADE7763 interrupt(like we have in RFM69_new library). Seems all look somewhat ok.
I think for RFM69 we use a default clock speed. for ADE7763: SPI_CLOCK_DIV4
Are you using pull up resistors on the CS lines to each device - that might be worth a try too....
Yes, I have