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;
}
@epierre said:
I had the contact with this seller, but an international money transfer was needed and is expensive...
yeah, they also have a minimum order quantity and ship with DHL only, so you have to pay import taxes to EU
so it only makes sense if you order a big quantitiy and then try to resell it somehow
all in all a hobby that at least has some return on investment, compared to other ones i had :))
You're courageous th have gone on kickstarter, from memory seeedstudio nearly went down because of an error on a crowdfunding project and had to produce and ship (the more expensive par of it) a remlacement for the first batches...
ahh .. i didnt know this about them... and in their scale - i can undertand
it happened to me as well but in my scale it was rather a paid lesson :))))
@YuryPol as far as I know, all licenses require some form of documentation. In all cases I know of, this is documented with the license or on the licenses official site.
@Michael-Link I have been out of touch with MySensors for some time now and looking to slowly get back into it. I created this and a few other boards back in 2018 All of the GERBER files for this are in the "Design Files" tab. Those you should be able to send to JLC PCB or one of the other fab houses and have some made. This was designed to be used with 2 other boards that I designed. There was the processor board and the power supply board. The processor board was designed in a way that I could use a couple different switch boards. This one and a universal multi-switch board that had multiple configurations. If you look here you will see my other boards.