NodeMCU Lua Amica v2 DeepSleep function - arduino

how can i put the NodeMCU Lua Amica v2 into deepSleep mode?
I read in much posts that it is just ESP.deepSleep() but in my case it doesn't work.
Because I want to make a simple weather station with humidity and temperature and the NodeMCU sends the data to Ubidots every hour and in the rest of the time I want it to be in deepSleep mode for better battery life, because I only use a powerbank.
Thanks for answers

dont forget when you wake up the esp, the code restart at beginning (write all your code in setup() and execute the ESP.deepSleep
the syntax of this function is (i suppose you are using the library)
ESP.deepsleep(duration, [wifi_state])
duration is in microsecond so duration = 1000000 * lapseInSecond
if you dont put wifi_state, is the default mode
if you put RF_DISABLED you dont use Wifi
so 1 hour = 3600 * 1000000 microseconds hope you could use int or long on 32 bits

Related

Is there a way to turn on LED on chassis panel in Dell blade

I have a Dell PowerEdge r630 blade which has a LED in chassis panel. I can turn it off or let it blink by running the following command:
ipmiutil -alarms -iN (N =0 for turning off, N = 255 for blinking)
I wonder if there's some commands to keep LED turned on instead of blinking. I tried some commands of ipmiutil but didn't get it work.
When reading http://ipmiutil.sourceforge.net/man.htm#ialarms, we see :
-iN Sets the Chassis Identify feature, which can be an LED or some
other alarm. If N=0, turn off the Chassis ID, otherwise turn
the ID on for N seconds. N=255 will turn on the ID indefi-
nitely, if it is IPMI 2.0.

MSP430 MEMORY ADDRESS IN CCS6

I've wrote my very first MSP-EXP430F5529LP LED on/off program.
and I wanted to analyze my program. but I had problem at my first step.
I extracted my LED program from board and I've got unclear data. (3)
that's my first question. what is that file format? I mean I want to know file format for my memory dump file. (3)
my second question is that why CCS 6 doesn't indicate memory address properly?
I know that MSP430 is 16 bit MCU. so every memory address should be 16 bit-width. but my assembly code(2) which is copied from CCS6 Disassembly View show me address just like 01XXXX format.
relative data dereference and execution flow branches work well. but why CSS6 make me confused? I mean I want to know that why CCS6 display memory addresse 24 bit-width??
anyone who know where is TI document which explain what I want to know, please let me know. please just don't mention MSP430xxxx User's Guide.
sorry for my english :(
1.c code
#include <msp430f5529.h>
volatile unsigned int i;
void main(void) {
WDTCTL = WDTPW | WDTHOLD;
P1DIR |= 0x01;
while(1){
P1OUT ^= 0x01;
for(i = 20000;i > 0; i--);
}
}
2.assembly code
0100c2: 40B2 5A80 015C MOV.W #0x5a80,&Watchdog_Timer_WDTCTL
0100c8: D3D2 0204 BIS.B #1,&Port_A_PADIR
0100cc: E3D2 0202 XOR.B #1,&Port_A_PAOUT
0100d0: 40B2 4E20 2400 MOV.W #0x4e20,&i
0100d6: 3C02 JMP (0x00dc)
0100d8: 8392 2400 DEC.W &i
0100dc: 9382 2400 TST.W &i
0100e0: 27F5 JEQ (0x00cc)
0100e2: 3FFA JMP (0x00d8)
0100e4: 4303 NOP
0100e6: D032 0010 BIS.W #0x0010,SR
0100ea: 3FFD JMP (0x00e6)
0100ec: 431C MOV.W #1,R12
0100ee: 0110 RETA
0100f0: 4303 NOP
0100f2: 3FFF JMP (0x00f2)
3.memory dump (MAIN)
:1044000031400044b113ec000c930224b1130000be
:104410000c43b113c200b113f00000000200000011
:10442000840001001a44000000240000ffffffff89
:10443000ffffffffffffffffffffffffffffffff8c
:10444000ffffffffffffffffffffffffffffffff7c
...
...
If one reads the User Guide (which is why they exist) then one is informed that the Program Counter is 20-bit. So, now you know why you see an address in the 20-bit range.
Link to the MSP430 User Guide: http://www.ti.com/lit/ug/slau208n/slau208n.pdf
The 20-bit PC (PC/R0) points to the next instruction to be executed.
Each instruction uses an even number of bytes (2, 4, 6, or 8 bytes),
and the PC is incremented accordingly. Instruction accesses are
performed on word boundaries, and the PC is aligned to even addresses.
Figure 6-3 shows the PC.
The above is an excerpt from the User Guide. I cannot emphasis this enough - but you really need to read the User Guide. Not doing so and attempting to program microcontrollers is perlious to your mental health.
The memory dump seems to be in the Intel hex file format https://en.wikipedia.org/wiki/Intel_HEX

Arduino Due output TIOA and TIOB without interrupts

I am an electrical student and want to use arduino due to generate pulses for driving MOSFETs. I am making a inverter and want to generate pulses. I have arduino due with me. My main aims are :
1) one software interrupt for sampling the next time period (this will be changing..). After three cycles I will analogRead() new value of time period and same continues .
2) During one time period,set by RC count of Timer channel TC0, I want to load RA0 and RB0 with appropriate counts to get output pulses with different duty ratios(depending on RA0 and RB0 values).
I wrote a program which gives software interrupts with TC3 which is working fine. i.e. I am able to load new values into RA0 and RB0 automatically for every new sampled value( every 3 cycles new values comes else same values will be loaded).
Now I also used TC0 (i used Olavi Kamppari's library) for stopping, loading new values and starting the timer.
when i checked PIO_PB25B_TIOA0 and PIO_PB27B_TIOB0 in the serial monitor i am getting 33554432,134217728 .
I am really confused.I expected a 1 and 0 output. I just want two pulses from TC0 without interrupt.I set the ACPA value to 3 (Toggle) and I enabled the clock to the timer as well.Still I am not getting the output.
So if possible please provide me a sample program that can output pulses from PB25 and PB27 (TIOA0 and TIOB0). Any help will be greatly appreciated.
Thanks for reading my question.
Thank you.
The following sketch outputs a 3 MHz signal on TIOA6 (Pin 5 from memory)
I am about to post a question regarding the same code - I want to get to 8 (and a little bit) MHz but have hit a conceptual brick wall!
Note that this is under development - the IRQ handler is not used - and the PMC_Enable_Periph should be referring to ID_TC6 (I believe) - then the IRQ handler can be placed in the dust bin of history!
void TC6_Handler()
{
TC_GetStatus(TC2, 0);
}
void startTimer(Tc *tc, uint32_t channel, IRQn_Type irq) {
pmc_set_writeprotect(false);
pmc_enable_periph_clk((uint32_t)irq);
TC_Configure(tc, channel,
TC_CMR_WAVE |
TC_CMR_WAVSEL_UP_RC |
TC_CMR_TCCLKS_TIMER_CLOCK1|
TC_CMR_ACPA_TOGGLE ); // RC compare TOGGLES TIOA)smiley-wink;
TC_SetRA(tc, channel, 1); //50% high, 50% low
TC_SetRC(tc, channel, 1);
PIO_Configure(PIOC,
PIO_PERIPH_B,
PIO_PC25B_TIOA6,
PIO_DEFAULT);
TC_Start(tc, channel);
}
void setup(){
startTimer(TC2, 0, TC6_IRQn);
}
void loop(){
}

Serial write from Processing to Arduino sending broken data

I'm new to Processing and serial communication and my problem seems very elementary. I'm trying to send data over from Processing to an Arduino but it seems that something gets lost in translation.
On Arduino I'm running this super simple sketch:
void setup()
{
Serial.begin(9600);
}
void loop()
{
if (Serial.available() > 0) Serial.println(Serial.read());
}
The intention there is to read a byte from serial and then write it right back so I can see what is going on. Testing this with the included serial monitor behaves as I'd expect: typing in "0" returns "48". So far so good.
Things start to go wrong when I run this Processing sketch:
import processing.serial.*;
Serial myPort;
void setup()
{
//frameRate(10);
myPort = new Serial(this, Serial.list()[4], 9600);
}
void draw()
{
myPort.write("0");
}
I woud expect this code to return an endless stream of "48" with the rate of ten entries per second, since I understand that is the default frame rate. What really happens is something like this:
48
48
488
48
48
48
48
48
48
48
48
48
48
488
48
48
48
It seems like every 10th (give or take a few) byte has a good change of being messed up. Instead of "48" I get back stuff like " ", "488", "4848" or "488". What's even more interesting is that if I uncomment the frameRate(10); line in my Processing script I would expect absolutely nothing to happen, since I'm setting the fps from ten to ten. Instead I start to see stuff like this:
4
44
4848844
444448444844
4
44444444
844
444
844444
8
88
8
4488
84
48
4448444844
444
So basically the numbers make so sense anymore.
It took me quite some time to narrow the problem down to this serial communication and a few hours of Googling around related topics has given me no hints about what might be going on. Any pointers toward further reading or things to try would be greatly appreciated.
I'm using the latest version of Processing downloaded today and my system is a MBP running Mountain Lion with all updates installed.
After some further testing, it seems that having the serial monitor on while sending bytes from Processing messes both up for a yet unknown reason. I assume there is some sort of fighting over serial bus priority and the data ends up broken.
Solution: don't try to use multiple programs to read serial data simultaneously.
As you have figured out, if you have multiple programs trying to read data from Serial, it could result it such problems.
You can also try out the Software Serial Arduino library, which allows you to use any pins as serial pins.
try replace:
myPort.write("0");
with:
myPort.write("0")-'0';
Because
ascii 0 --> 48
ascii 1 --> 49
.
.
.

Failed to generate 1 second (BASCOM AVR)

I had a microcontroller trainer kit that includes ATMEGA8535 and 8MHZ xtal. I want to make simple program that switch off/on led every 1 sec.
But it wont work, when I run the trainer, the delay seems to be 7 sec.
here the program with BASCOM AVR.
$regfile = "8535def.dat"
$crystal = 8000000
Config Porta = Output
Config Timer1 = Timer , Prescale = 256
Enable Timer1
On Timer1 Isr_von_timer1
Enable Interrupts
Timer1 = 34285
Do
Loop
End
Isr_von_timer1:
Timer1 = 34285
Toggle Porta.0
Return
I've resolved the issue: I forgot to activate the external xtal :).
The correct value for timer1 using an 8 MHz oscillator with pre-scale=256 to turn on the output for one second and turn off for one second using the toggle command is 31249 (divisor - 1)

Resources