I wrote simple code in arduino IDE like this :
void setup() {
pinMode(PC4,OUTPUT);
pinMode(PC5,INPUT);
}
void loop() {
if(analogRead(PC5)<15)
digitalWrite(PC4,LOW);
else
digitalWrite(PC4,HIGH);
}
and my problem is the arduino IDE defined PC4 as PD4, PC5 defined as PC5.
Use A4 and A5 to specify pins PC4 and PC5 respectively
Like pinMode(A4, OUTPUT)
Related
is it possible to send a lora payload from a T-Beam and receive it from a LoRa32 SX1276 OLED (v2) ? I if follow those two tutorials:
https://randomnerdtutorials.com/ttgo-lora32-sx1276-arduino-ide/ or https://randomnerdtutorials.com/esp32-lora-rfm95-transceiver-arduino-ide/, i can send and receive without problem from two LoRa32 devices.
But if i let the LoRa32 receiver ON and tries to send from a T-Beam T22V1.0, nothing seems to happen.
T-beam code: (some gps related vars are set but i removed gps code for clarity. GPS does work fine.)
What am i doing wrong ?
(if i am not in the good place for that kind of beginner issue, please tell me and i'll try to find a more suitable place for this..)
#include <TinyGPS++.h>
#include <axp20x.h>
#include <SPI.h>
#include <LoRa.h>
#define SCK 5 // GPIO5 -- SX1278's SCK
#define MISO 19 // GPIO19 -- SX1278's MISnO
#define MOSI 27 // GPIO27 -- SX1278's MOSI
#define SS 18 // GPIO18 -- SX1278's CS
#define RST 23 // GPIO14 -- SX1278's RESET
#define DI0 26 // GPIO26 -- SX1278's IRQ(Interrupt Request)
#define BAND 868E6
TinyGPSPlus gps;
HardwareSerial GPS(1);
AXP20X_Class axp;
void setup()
{
Serial.begin(115200);
Wire.begin(21, 22);
if (!axp.begin(Wire, AXP192_SLAVE_ADDRESS)) {
Serial.println("AXP192 Begin PASS");
} else {
Serial.println("AXP192 Begin FAIL");
}
axp.setPowerOutPut(AXP192_LDO2, AXP202_ON); //lora
axp.setPowerOutPut(AXP192_LDO3, AXP202_ON); //gps
axp.setPowerOutPut(AXP192_DCDC2, AXP202_ON);
axp.setPowerOutPut(AXP192_EXTEN, AXP202_ON);
axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON); //oled
GPS.begin(9600, SERIAL_8N1, 34, 12); //17-TX 18-RX
SPI.begin(SCK,MISO,MOSI,SS);
LoRa.setPins(SS,RST,DI0);
if (!LoRa.begin(BAND)) {
Serial.println("Starting LoRa failed!");
while (1);
}else{
Serial.println("Starting LoRa succeed!");
}
axp.setChgLEDMode(AXP20X_LED_BLINK_1HZ);
}
void loop()
{
LoRa.beginPacket();
LoRa.print("Hello");
LoRa.endPacket();
Serial.println("sent..");
delay(1000);
}
Thanks :)
[EDIT]
I tried to use https://github.com/Extentsoftware/TBeamPower.
Still nothing.
Here is the code:
#include <Arduino.h>
#include <SPI.h>
#include <LoRa.h> // https://github.com/sandeepmistry/arduino-LoRa/blob/master/API.md
#include "gps.h"
#include "TBeamPower.h"
TBeamPower power(PWRSDA, PWRSCL); //21 22
void setupSerial() {
Serial.println();
power.print_wakeup_reason();
}
void setup() {
Serial.begin(115200);
while (!Serial);
Serial.println("Power begin");
power.begin();
Serial.println("All sensors off");
power.power_sensors(false);
Serial.println("All peripherals off");
power.power_peripherals(false);
Serial.println("Powering LoRa");
power.power_LoRa(true);
SPI.begin(SCK,MISO,MOSI,SS); //5 19 27 18
LoRa.setPins(SS,RST,DI0); //18 14 26
if (!LoRa.begin(BAND)) { //868E6 (France)
Serial.println("Starting LoRa failed!");
while (1);
}else{
Serial.println("Starting LoRa succeed!");
}
Serial.println();
}
void loop() {
power.led_onoff(true);
delay(500);
power.led_onoff(false);
LoRa.beginPacket();
LoRa.print("hello");
LoRa.endPacket();
Serial.println("sent..");
power.print_status();
Serial.println();
delay(2000);
}
And here is the output i get
Power begin
AXP192 Begin PASS
All sensors off
All peripherals off
Powering LoRa
Starting LoRa succeed!
sent..
Voltages:
DCDC1: 3.30v
DCDC2: 1.25v
DCDC3: 3.30v
LDO2: 3.30v
LDO3: 2.80v
ChargeCurrent: 0.70A
IPSOUTVoltage: 3.57v
Temp: 15.94°C
TSTemp: 800.00
VbusCurrent: 0.00
VbusVoltage: 0.00
Battery:
Connected: false
Charging: false
ChargEN : true
Voltage: 0.00v
Inpower: 0.00
DischgCur: 0.00
ChargeCur: 0.00
I even tried to change the antenna.
I also tried to make the TBeam as receiver, and nothing arrived.
I had the same issue using one t-beam to send and a second to receive. The solution was to cycle power to both boards. Doing a reset or uploading the code does not do the same thing. I spent hours looking at my code and trying different things until I cycled power to both boards. I can finally work on the code for my project. Lilygo documentation is very minimal and some of the example code does not work.
They should work provided the frequencies are the same,
Check if both the T-Beam as well as the LoRa32 modules operate in the same frequency. Lora supports different frequencies. If you check in the links you provided you will see the following code:
//433E6 for Asia
//866E6 for Europe
//915E6 for North America
#define BAND 866E6
Whereas in your T-Beam code there is
#define BAND 868E6
So maybe you have a problem here.
I have a DS1302 RTC board (Waveshare) connected to an Arduino uno.
I'm printing time to Arduino's Serial Monitor but I get weird numbers/characters, and after 2-4 seconds it stops printing.
Wiring:
Vcc -> 5v
GND -> GND
I/O (MISO) -> Pin 12
SCLK -> Pin 13
CE (CS) -> Pin 10
Library used: VirtuabotixRTC library.
Things I've tried so far:
I tried a second DS1302 RTC board.
I tried a different Arduino board.
I tried changing the jumper wires.
I tried different baud rates.
Code:
#include <virtuabotixRTC.h>
virtuabotixRTC myRTC(7,8,9);
void setup() {
Serial.begin(9600);
// myRTC.setDS1302Time(30,30,5,5,5,5,2020);
}
void loop() {
myRTC.updateTime();
Serial.print(myRTC.hours);
Serial.print(":");
Serial.print(myRTC.minutes);
Serial.print(":");
Serial.println(myRTC.seconds);
}
Screenshots:
I am using an A-Star 32U4 Micro Arduino and I'm trying to connect the RDM6300 - 125KHz Cardreader Mini-Module.
I'm using this sketch at the moment:
#include <SoftwareSerial.h>
// RFID | Nano
// Pin 1 | D2
// Pin 2 | D3
SoftwareSerial Rfid = SoftwareSerial(2,3);
void setup() {
// Serial Monitor to see results on the computer
Serial.begin(9600);
// Communication to the RFID reader
Rfid.begin(9600);
}
void loop() {
// check, if any data is available
if(Rfid.available() > 0 ){
// as long as there is data available...
while(Rfid.available() > 0 ){
// read a byte
int r = Rfid.read();
// print it to the serial monitor
Serial.print(r, DEC);
Serial.print(" ");
}
// linebreak
Serial.println();
}
}
With this circuit:
module TX --- Arduino pin 2
module VCC ----- 5v
module ground ---- ground
antenna pins ---- antenna
When I put the card in the sensor nothing shows up on serial port. I tried this setup and the exact same sensors on an Arduino Uno (same sketch) and it worked perfectly, but I cant get this working on the Micro.
Arduino UNO and Micro uses different processors, though they work fairly similarly, they are not totaly identical.
It seams that
not all pins on the Leonardo and Micro support change interrupts, so only the following can be used for RX: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).
From the SoftwareSerial Library description ( https://www.arduino.cc/en/Reference/softwareSerial )
Change the module TX from pin 2 to pin 8. and you should be good. :-)
I am trying to interface with the MPU-6050 as part of a robotics project using the Texas Instruments TM4C123G LaunchPad. I am uploading code onto this from Energia and am using the serial monitor to see the raw data output, however I am only receiving the following output when I upload it to the micro controller and run it:
Initialising I2C devices...
Here is the code that I am trying to run:
#include <Wire.h>
#include <I2Cdev.h>
#include <MPU6050.h>
MPU6050 accelgyro;
void Setup_MPU6050()
{
Wire.begin();
Serial.println("Initialising I2C devices...");
accelgyro.initialize();
Serial.println("Testing device connections...");
Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");
}
void Update_MPU6050()
{
int16_t ax, ay, az;
int16_t gx, gy, gz;
accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
Serial.print("i");Serial.print("\t");
Serial.print(ax);Serial.print("\t");
Serial.print(ay);Serial.print("\t");
Serial.print(az);Serial.print("\t");
Serial.print(gx);Serial.print("\t");
Serial.print(gy);Serial.print("\t");
Serial.println(gz);
Serial.print("\n");
}
void setup()
{
Serial.begin(115200);
Setup_MPU6050();
}
void loop()
{
Update_MPU6050();
}
The pins on the breakout board are connected to the Launchpad as follows:
VDD -> Pin 1 (3.3v)
GND -> Pin 12 (GND)
INT -> Pin 34 (PF0)
FSYNC -> None
SCL -> Pin 13 (PD0)
SDA - > Pin 14 (PD1)
VIO -> None
CLK -> None
ASCL -> None
ASDA -> None
I have got the MPU6050 and I2Cdev libraries from GitHub and have got the Wire library from github.com/codebendercc/arduino-library-files/blob/master/libraries/Wire/Wire.h but am thinking that either the wire.begin() or accelgyro.initialize() methods are not functioning properly? I am a relative beginner when it comes to programming in this language but I am undertaking an ambitious task to create a robot for a scholarship that I am applying for, and would therefore appreciate some assistance on this subject area.
I just met the same question as you. Here is a useful linkage:
enter link description here
I referred it and added some code before
Wire.begin()
--just like this
enter image description here
then I upload it and run, it works perfectly. And there is another thing to be minded that you can't connect INT pin when you don't use DMP but when you use DMP then you must connect INT pin.
I try to explain it.
Why should we add the two lines codes? The Library is from Arduino, although Energia is compatible with Arduino programming in most cases but not always. So we should explictly acclaim something.
And why should we pay attention the interruption. Because when we use DMP we use it, if we don't connect the INT pin, it willn't work normally.
When I'm trying to build what seems to be any code in the Arduino IDE, it fails with this error:
Arduino: 1.6.5 (Mac OS X), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"
/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/USBCore.cpp:19:19: fatal error: Reset.h: No such file or directory
#include "Reset.h"
^
compilation terminated.
Error compiling.
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
The code I'm trying to build is from https://www.arduino.cc/en/Tutorial/Fade:
/*
Fade
This example shows how to fade an LED on pin 9
using the analogWrite() function.
The analogWrite() function uses PWM, so if
you want to change the pin you're using, be
sure to use another PWM capable pin. On most
Arduino, the PWM pins are identified with
a "~" sign, like ~3, ~5, ~6, ~9, ~10 and ~11.
This example code is in the public domain.
*/
int led = 9; // the PWM pin the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by
// the setup routine runs once when you press reset:
void setup() {
// declare pin 9 to be an output:
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// set the brightness of pin 9:
analogWrite(led, brightness);
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount ;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
Why is this happening? I don't think I've changed any of the Arduino libraries, but wondering if that's the case now. A find in /Applications/Arduino.app/ lists no files called Reset.h, however, I did find a ~/Library/Arduino15/packages/arduino/hardware/sam/1.6.4/cores/arduino/Reset.h.
Building with Arduino IDE 1.6.5, using a Mega 2560 and /dev/cu.usbmodem1421.
It turns out my Android installation was modified, and the modified USBCore.cpp wasn't really correct for this version (1.6.5) of Arduino. Reinstalling fixed the problem.