alex72:
Bonjour!
Je te conseille aussi les NRF24, je les utilise avec succès et sur de bonnes distances. Pour autonomie, je te conseille des arduino pro mini 3v3, tu prends une pince et tu casse la led smd liée à la pin 13 tu gagneras déjà quelques ma. Tu peux aussi utiliser l'horloge interne avec un programmateur externe. Ensuite désactives tout ce qui ne t'es pas utile de manière logicielle(ADC..)...bref la bidouilla après ] Perso j'arrive à une consommation de 32ua en mode veille.
Bonne chance!
Alex.
Salut!
J'avais la même idée que toi de casser la led, avec 32µA, cela fait une autonomie de prés de 5ans! Oregon Embedded - Battery Life Calculator Pas mal du tout!
Je vais essayer, en attendant je viens de recevoir mon MSP430 Launchpad, c'est bien conçu et Energia est magnifique! Un véritable clone de l'arduino, c'est agréable!!!
J'ai essayé de suivre ce tuto pour l'utilisation avec NRF24L01 : [Tutorial] Le Nrf24L01, l’Arduino et le MSP 430. | B@ttoMicro - Microcontrôleurs et compagnie ! ainsi que la librairie : GitHub - spirilis/msprf24: nRF24L01+ Library for MSP430 microcontroller line :
#include <msp430.h>
#include "msprf24.h"
#include "nrf_userconfig.h"
char addrTX[]={'t','e','s','t','2'};
char buf[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; // trame exemple
int main(void) {
WDTCTL = WDTPW + WDTHOLD;
BCSCTL2 = SELM_0 + DIVM_0 + DIVS_0;
if (CALBC1_1MHZ != 0xFF) {
DCOCTL = 0x00;
BCSCTL1 = CALBC1_1MHZ; /* Set DCO to 1MHz */
DCOCTL = CALDCO_1MHZ;
}
BCSCTL1 |= XT2OFF + DIVA_3;
BCSCTL3 = XT2S_0 + LFXT1S_0 + XCAP_0;
TA0CCTL0 = CM_0 + CCIS_0 + OUTMOD_0 + CCIE; // configuration du timer à 1 s
TA0CCR0 = 4095;
TA0CTL = TASSEL_1 + ID_0 + MC_1;
UCB0CTL1 |= UCSWRST; // configuration du SPI
UCB0CTL0 = UCMSB + UCMST + UCMODE_0 + UCSYNC;
UCB0CTL1 = UCSSEL_2 + UCSWRST;
UCB0BR0 = 64;
UCB0BR1 = 6;
UCB0CTL1 = ~UCSWRST;
P1DIR|=BIT0;
rf_crc=RF24_EN_CRC|RF24_CRCO; // CRC active, 16-bit
rf_addr_width=5; // On utilise une adresse de 5 bytes
rf_speed_power=RF24_SPEED_2MBPS|RF24_POWER_0DBM; // vitesse 1MBPS et puissance max
rf_channel=1;
msprf24_init();
msprf24_set_pipe_packetsize(0,16); // payload de 16 byte sur le pipe 0
msprf24_open_pipe(0,1); // ouverture du pipe avec Auto-Acknowledgement
w_tx_addr(addrTX); // configuration adresse émission
w_rx_addr(0,addrTX); // configuration adresse réception idem à celle de transmission
// pour permettre la réception de l'ACK
msprf24_standby(); // module en veille (pas endormi)
while(1){
if(msprf24_is_alive()) { // fait clignoter la LED rouge sur launchpad si
P1OUT^=BIT0; // le nrf est bien connecté
}else{
P1OUT&=!BIT0;
}
LPM3; // on endort
w_tx_payload(16,buf); // on charge le FIFO avec le tableau buf
msprf24_activate_tx(); // émission
msprf24_get_irq_reason(); // récupère les alertes du NRF
while(!(rf_irq && RF24_IRQ_TX)) msprf24_get_irq_reason(); // tant que la transmission n’est pas finie, on boucle
msprf24_irq_clear(RF24_IRQ_TX); // on efface les flags d’alerte
}
}
#pragma vector=TIMER0_A0_VECTOR
__interrupt void TIMER0_A0_ISR_H
Le fichier "nrf_userconfig.h" contient :
/* nrf_userconfig.h
* User configuration of nRF24L01+ connectivity parameters, e.g.
* IRQ, CSN, CE pin assignments, Serial SPI driver type
*
*
* Copyright (c) 2012, Eric Brundick <spirilis@linux.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose
* with or without fee is hereby granted, provided that the above copyright notice
* and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
* OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _NRF_USERCONFIG_H
#define _NRF_USERCONFIG_H
/* CPU clock cycles for the specified amounts of time--accurate minimum delays
* required for reliable operation of the nRF24L01+'s state machine.
*/
/* Settings for 1MHz MCLK.
#define DELAY_CYCLES_5MS 5000
#define DELAY_CYCLES_130US 130
#define DELAY_CYCLES_15US 15
*/
/* Settings for 8MHz MCLK.
#define DELAY_CYCLES_5MS 40000
#define DELAY_CYCLES_130US 1040
#define DELAY_CYCLES_15US 120
*/
/* Settings for 16MHz MCLK */
#define DELAY_CYCLES_5MS 80000
#define DELAY_CYCLES_130US 2080
#define DELAY_CYCLES_15US 240
/* Settings for 24MHz MCLK.
#define DELAY_CYCLES_5MS 120000
#define DELAY_CYCLES_130US 3120
#define DELAY_CYCLES_15US 360
*/
/* SPI port--Select which USCI port we're using.
* Applies only to USCI devices. USI users can keep these
* commented out.
*/
//#define RF24_SPI_DRIVER_USCI_A 1
#define RF24_SPI_DRIVER_USCI_B 1
/* Define whether this library should use LPM0+IRQs during SPI I/O and whether this library should provide the ISR. */
#define RF24_SPI_DRIVER_USCI_USE_IRQ 1
#define RF24_SPI_DRIVER_USCI_PROVIDE_ISR 1
/* Operational pins -- IRQ, CE, CSN (SPI chip-select)
*/
/* IRQ */
#define nrfIRQport 2
#define nrfIRQpin BIT2
/* CSN SPI chip-select */
#define nrfCSNport 2
#define nrfCSNportout P2OUT
#define nrfCSNpin BIT1
/* CE Chip-Enable (used to put RF transceiver on-air for RX or TX) */
#define nrfCEport 2
#define nrfCEportout P2OUT
#define nrfCEpin BIT0
#endif
Dans le tuto il indique :
Modification du nrf_userconfig.h : en haut il y des constantes suivant la fréquence de fonctionnement, il suffit de décommenter la partie qui vous correspond et de commenter les autres et en bas la partie hardware pour définir où sont brancher les pins CE, CSN et IRQ si vous l’utilisez
Je ne sais pas à quelle pin physique correspond les BIT0, BIT1 et BIT2 pour regler en fonction du pinage que j'utilise :
P1.5: SCK
P1.6: MISO
P1.7: MOSi
P2.0: CE
P2.1: CSN
P2.2: IRQ
Je recontre une erreur de compilation :
sketch_jul18a.cpp.o: In function main': C:\Users\acer\AppData\Local\Temp\build4513026607041527577.tmp/sketch_jul18a.cpp:40: undefined reference to
msprf24_init()'
C:\Users\acer\AppData\Local\Temp\build4513026607041527577.tmp/sketch_jul18a.cpp:42: undefined reference to msprf24_set_pipe_packetsize(unsigned char, unsigned char)' C:\Users\acer\AppData\Local\Temp\build4513026607041527577.tmp/sketch_jul18a.cpp:43: undefined reference to
msprf24_open_pipe(unsigned char, unsigned char)'
C:\Users\acer\AppData\Local\Temp\build4513026607041527577.tmp/sketch_jul18a.cpp:45: undefined reference to w_tx_addr(char*)' C:\Users\acer\AppData\Local\Temp\build4513026607041527577.tmp/sketch_jul18a.cpp:46: undefined reference to
w_rx_addr(unsigned char, char*)'
C:\Users\acer\AppData\Local\Temp\build4513026607041527577.tmp/sketch_jul18a.cpp:49: undefined reference to msprf24_standby()' C:\Users\acer\AppData\Local\Temp\build4513026607041527577.tmp/sketch_jul18a.cpp:53: undefined reference to
msprf24_is_alive()'
C:\Users\acer\AppData\Local\Temp\build4513026607041527577.tmp/sketch_jul18a.cpp:61: undefined reference to w_tx_payload(unsigned char, char*)' C:\Users\acer\AppData\Local\Temp\build4513026607041527577.tmp/sketch_jul18a.cpp:62: undefined reference to
msprf24_activate_tx()'
C:\Users\acer\AppData\Local\Temp\build4513026607041527577.tmp/sketch_jul18a.cpp:63: undefined reference to msprf24_get_irq_reason()' C:\Users\acer\AppData\Local\Temp\build4513026607041527577.tmp/sketch_jul18a.cpp:64: undefined reference to
msprf24_get_irq_reason()'
C:\Users\acer\AppData\Local\Temp\build4513026607041527577.tmp/sketch_jul18a.cpp:65: undefined reference to `msprf24_irq_clear(unsigned char)'
collect2: ld returned 1 exit status
Merci et bonne journée!!!