EUREKA!!!!
With this setup it works
Wire.begin(26, 32); // (sda, sck)
M5.begin(true, false, true);
Serial.begin(115200);
EUREKA!!!!
With this setup it works
Wire.begin(26, 32); // (sda, sck)
M5.begin(true, false, true);
Serial.begin(115200);
tnks a lot!!!
this one compile & no error in serial monitor
/* Ultrasonic distance sensor example - Better Version
Paul Carpenter, PC Services
26-Jan-2017
Update 4-Feb-2017 PC make variables more obvious
Update 13-May-2017 PC add half bit rounding to distance calculation
Uses HC-SR04 four pin ultrasonic sensor to continuously output distances
found when in range (every second).
Results WHEN valid output onto serial port at 115,200 baud
Both LEDs ON when program starts and any other time for no start of echo
received (probably bad wiring or faulty unit) on start up also serial port
error string
Lights RED Led when No Reading received or out of range
Lights Yellow LED when too close (less than 5 cm)
LEDs are connected via 330R or similar resistor other end of LED to GND
Works on principle sound travels at 343.2 m/s in dry STILL air at 20 deg C
So time per cm is 29.137529 micro seconds /cm
For round trip (there and back) 58.275058 micro seconds /cm
In order to reduce code size and execution time values are kept as integers
and factor of 58 to calculate distances
*/
/* Pin definitions */
#define echopin 21
#define trigpin 22
//#define redled 6
//#define yellowled 7
/* time between readings in ms
On Arduino Mega readings belown 20ms interval could
have residual echo issues */
#define INTERVAL 30
/* Scale factor round trip micro seconds per cm */
#define SCALE_CM 58
#define SCALE_CM_ROUND (SCALE_CM/2)
/* Timeout for distance sensing rather than 1 second in us */
#define MAX_ECHO 300000
#define MIN_ECHO (3 * SCALE_CM)
/* Timeout for start of ECHO pulse being received in us */
#define MAX_START_ECHO 1000
/* Limits for application ranges in cm */
#define MIN_RANGE 4
#define MAX_RANGE 500
#define MAX_ERROR 10
/* calculated distance in centimetres */
unsigned long distance;
unsigned int echotime;
unsigned long next_time, new_time;
/* Distance sensor function to get echo time
Note most ultrasonic distance sensors are only usable beyond 3 cm
So usable range is 3 * SCALE_CM to MAX_ECHO, therefore anything below
3 * SCALE_CM should be treated as error
Returns echo time in microseconds
Maximum MAX_ECHO
Minimum 3 * SCALE_CM (minimum usable)
error codes
Error 2 Echo HIGH before start
Error 1 Echo did not start
Error 0 NO ECHO (Timeout)
Timeout for measurements set by MAX_ECHO
*/
unsigned long GetEchoTime( )
{
unsigned long start_time;
unsigned long end_time;
/* check Echo if high return error */
if( digitalRead( echopin ) )
return( 2 );
/* note start time */
start_time = micros( );
/* send the trigger pulse */
digitalWrite( trigpin, HIGH );
delayMicroseconds( 10 );
digitalWrite( trigpin, LOW );
/* Set timeout for start of echo pulse */
end_time = start_time + MAX_START_ECHO;
/* check ECHO pin goes high within MAX_START_ECHO
if not return error of 1 */
while( !digitalRead( echopin ) )
if( micros( ) > end_time )
return( 1 );
/* Check for Length of echo occurred or timeout */
start_time = micros( );
end_time = start_time + MAX_ECHO;
while( digitalRead( echopin ) )
if( micros( ) > end_time )
break;
end_time = micros( );
/* Return time or timeout */
return( ( start_time < end_time ) ? end_time - start_time: 0 );
}
void setup( )
{
/* set time from reset */
next_time = INTERVAL;
Serial.begin( 115200 );
/* Configure pins and ensure trigger is OFF */
pinMode( trigpin, OUTPUT );
digitalWrite( trigpin, LOW );
pinMode( echopin, INPUT );
/* Configure LED drive and both LEDs On at start up */
//pinMode( redled, OUTPUT );
//pinMode( yellowled, OUTPUT );
//digitalWrite( redled, HIGH );
//digitalWrite( yellowled, HIGH );
/* Send signon message */
Serial.println( F( "PC Services - Better Range test" ) );
/* Do test reading to check if unit connected */
distance = GetEchoTime( );
if( distance > 0 && distance <= 10 )
{
Serial.println( F( "No unit found - Error = " ) );
Serial.println( distance );
}
}
void loop( )
{
new_time = millis( ); /* check if to run this time */
if( new_time >= next_time )
{
/* Turn LEDs Off */
// digitalWrite( redled, LOW );
// digitalWrite( yellowled, LOW );
/* Calculate distance */
echotime = GetEchoTime( );
/* only scale valid readings 0 is timeout or 1 is no echo
realistically minimum accurate or physical range is 3cm */
if( echotime > MAX_ERROR )
{
// Valid number covert to cm
distance = echotime;
distance += SCALE_CM_ROUND; // add in half bit rounding
distance /= SCALE_CM;
}
/* catch errors first */
if( echotime <= MAX_ERROR || distance > MAX_RANGE )
{
// digitalWrite( redled, HIGH ); // Range error too large
if( echotime > 0 && echotime <= MAX_ERROR )
// digitalWrite( yellowled, HIGH ); // Light 2nd LED error
Serial.println("MAX");
}
else
if( distance < MIN_RANGE )
// digitalWrite( yellowled, HIGH ); // Range too close
Serial.println("MIN");
else
Serial.println( int( distance ) ); // In range output distance
next_time = new_time + INTERVAL; // save next time to run
}
}
the first sketch works, with M5Stack basic, if I modify the M5Stack.cpp library from:
// TF Card
if (SDEnable == true) {
SD.begin(TFCARD_CS_PIN, SPI, 40000000);
}
to
// TF Card
if (SDEnable == true) {
SD.begin(TFCARD_CS_PIN, SPI, 10000000);
}
@macsbug said in ATOM Lite Display not display in smallHd 503:
1920/2,1080/2,24
No way to display something on the 503.... I tried all configuration:
// M5AtomDisplay display(); // 1280 x 720
M5AtomDisplay display(1920,1080,24); // 1920 x 1080 , 24bit
// M5AtomDisplay display(1366,768); // 1366 x 768
// M5AtomDisplay display(1920/2,1080/2,24);
// ( 480, 1920);(1920, 480);(1280, 720);(1024, 768);
// ( 960, 540);( 800, 600);( 640, 480);( 640, 400);
// ( 640, 360);( 512, 212);( 256, 192);( 320, 240);
// ( 240, 320);( 200, 200);( 240, 135);( 135, 240);
// ( 160, 160);( 160, 80);( 80, 160);( 80, 80);
when I connect hdmi cable to the 503, the monitor "feel" something (green led on and image settings in the "in settings page" of 503) but no image displayed.....
the same cable works in other setup....
/*
This example shows how to take simple range measurements with the VL53L1X. The
range readings are in units of mm.
*/
#include <Wire.h>
#include <VL53L1X.h>
VL53L1X sensor;
void setup()
{
Serial.begin(115200);
//Wire.begin();
Wire.begin(25, 13); // (SDA, SCL) grove stick
//Wire.begin(21, 22); // (SDA, SCL) grove stack
Wire.setClock(400000); // use 400 kHz I2C
sensor.setTimeout(500);
if (!sensor.init())
{
Serial.println("Failed to detect and initialize sensor!");
while (1);
}
// Use long distance mode and allow up to 50000 us (50 ms) for a measurement.
// You can change these settings to adjust the performance of the sensor, but
// the minimum timing budget is 20 ms for short distance mode and 33 ms for
// medium and long distance modes. See the VL53L1X datasheet for more
// information on range and timing limits.
sensor.setDistanceMode(VL53L1X::Long);
sensor.setMeasurementTimingBudget(50000);
// Start continuous readings at a rate of one measurement every 50 ms (the
// inter-measurement period). This period should be at least as long as the
// timing budget.
sensor.startContinuous(50);
}
void loop()
{
//Serial.print(sensor.read()); //MM
Serial.print(sensor.read()/10); //CM
if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }
Serial.println();
}
it works!!!
from SmallHD503 datasheet:
HDMI Input Types
YCC 4:2:2 @ 8 bits, 8/10/12 bit color in RGB & YCC 4:4:4: 1080p60, 1080p59.94, 1080p50, 1080p30, 1080p29.97 1080p25, 1080p24, 1080p23.98,1080i60, 1080i59.94, 1080i50, 1080i30, 1080i29.97, 1080i25, 720p120, 720p119.88, 720p100, 720p60, 720p59.94 , 720p50, 720p30, 720p29.97, 720p25, 720p24, 720p23.98, 480p120, 480p119.88, 480p60, 480p59.94, 576p100, 576p50, 480i240, 480i239.76, 480i120, 480i119.88, 480i60, 480i59.94, 480i30, 480i29.97, 480i24, 480i23.98, 576i200, 576i100, 576i50, 576i25
I'm trying to upload a new firmware on the unit roller connecting a ST_Link v2 to the SPI connector with STM32CubeProgrammer.
V --------------------- 3.3
G -------------------- GND
C ------------------ SWCLOCK
D ------------------ SWDIO
O ------------------- NC
when the firmware si uploaded the unit roller works (display right boot image and information, led is on, button and encoder works and menu works too), but if I disconnect the SPI cable and I power the unit from grove or dc in 6/16v, the unit doesn't work(black display, led off, etc).
this is the .hex firmware used.
and this is the cube log:
22:11:59 : MASS ERASE ...
22:11:59 : Mass erase successfully achieved
22:11:59 : UPLOADING ...
22:11:59 : Size : 1024 Bytes
22:11:59 : Address : 0x8000000
22:11:59 : Read progress:
22:11:59 : Data read successfully
22:11:59 : Time elapsed during the read operation is: 00:00:00.019
22:12:36 : Opening and parsing file: ROLLERCAN.hex
22:12:36 : Memory Programming ...
22:12:36 : File : ROLLERCAN.hex
22:12:36 : Size : 94.38 KB
22:12:36 : Address : 0x08002000
22:12:36 : Erasing memory corresponding to segment 0:
22:12:36 : Erasing internal memory sectors [4 51]
22:12:37 : Download in Progress:
22:12:39 : File download complete
22:12:39 : Time elapsed during download operation: 00:00:02.735
22:12:39 : Verifying...
22:12:39 : Read progress:
22:12:39 : Time elapsed during verifying operation: 00:00:00.645
22:12:39 : Download verified successfully
22:12:39 : Memory [0x08000000 : 0x08020000] - Checksum : 0x011ED0C0
22:12:39 : RUNNING Program ...
22:12:39 : Address: : 0x08002000
22:12:39 : Application is running, Please Hold on...
22:12:39 : Start operation achieved successfully
this is the log of OB:
{
"deviceId" : 1128,
"bitNameToValue" : {
"RDP" : 170,
"BOR_LEV" : 0,
"nRST_STOP" : 1,
"nRST_STDBY" : 1,
"nRST_SHDW" : 1,
"IWDG_SW" : 1,
"IWDG_STOP" : 1,
"IWDG_STDBY" : 1,
"WWDG_SW" : 1,
"nBOOT1" : 1,
"SRAM_PE" : 1,
"CCMSRAM_RST" : 1,
"nSWBOOT0" : 1,
"nBOOT0" : 1,
"NRST_MODE" : 3,
"IRHEN" : 1,
"PCROP1_STRT" : 16383,
"PCROP1_END" : 0,
"PCROP_RDP" : 0,
"WRP1A_STRT" : 63,
"WRP1A_END" : 0,
"WRP1B_STRT" : 63,
"WRP1B_END" : 0,
"SEC_SIZE1" : 0,
"BOOT_LOCK" : 0
}
}
If I power the unit from grove or DC in, I have 3.3v on SPI (V,G).
I tried to merge and burn a bootloader.hex too but no joy.
after uploading the firmware if I connect the grove cable of an atom lite running a i2c scanner code, I can see 0x64 on serial monitor. I can also disconnect the SPI cable and the roller still works until a power cycle.
ideas??
tnks a lot!!
tnks for answer.
an I2C scanner doesn't see any address when the unit_roller is connected to the controller running i2c scanner code. so I can't send i2c commands.
the motor moves only by hand.
the display motor say E4 Over Range.
if I go in to the menu (button pressed during power on), I can't navigate in the menu and there are missing items in the menu item list. the only possible selectable item is "quit".
I'm looking for the way to flash a new firmware on the unit.......
ideas??
Hi all,
after some test, Unit_Roller stops to work. now the motor doesn't move, the display say: E:4 Over Range. I can't make any selection in the config menu (there are missing items in the menu and no way to move the selection from "Quit").
any tips to reset and clear the error?
best regards
@henryCharm tnks for answering.. I'm talking about this LLM630 .. I red somewhere this llm630_compute_kit has a esp32 for wifi tasks..
Hi All,
I'm searching information about the possibility of sending data from llm630 via espnow. is it possible? if yes, how? I need to hard modify the pcb?
ciaoo
best regard
Hi all, I would like to play with atom s3r cam to send photo on telegram ..
this is the last not working code I try..
#include <Arduino.h>
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include "soc/soc.h"
#include "soc/rtc_cntl_reg.h"
#include "esp_camera.h"
#include <UniversalTelegramBot.h>
#include <ArduinoJson.h>
const char* ssid = "mywifi";
const char* password = "mywifipassword";
// Initialize Telegram BOT
String BOTtoken = "mybottoken"; // your Bot Token (Get from Botfather)
// Use @myidbot to find out the chat ID of an individual or a group
// Also note that you need to click "start" on a bot before it can
// message you
String CHAT_ID = "mychatid";
bool sendPhoto = false;
WiFiClientSecure clientTCP;
UniversalTelegramBot bot(BOTtoken, clientTCP);
#define FLASH_LED_PIN 4
bool flashState = LOW;
//Checks for new messages every 1 second.
int botRequestDelay = 1000;
unsigned long lastTimeBotRan;
//CAMERA_MODEL_AI_THINKER
#define PWDN_GPIO_NUM -1
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 21
#define SIOD_GPIO_NUM 12
#define SIOC_GPIO_NUM 9
#define Y9_GPIO_NUM 13
#define Y8_GPIO_NUM 11
#define Y7_GPIO_NUM 17
#define Y6_GPIO_NUM 4
#define Y5_GPIO_NUM 48
#define Y4_GPIO_NUM 46
#define Y3_GPIO_NUM 42
#define Y2_GPIO_NUM 3
#define VSYNC_GPIO_NUM 10
#define HREF_GPIO_NUM 14
#define PCLK_GPIO_NUM 40
void configInitCamera(){
camera_config_t config;
config.ledc_channel = LEDC_CHANNEL_0;
config.ledc_timer = LEDC_TIMER_0;
config.pin_d0 = Y2_GPIO_NUM;
config.pin_d1 = Y3_GPIO_NUM;
config.pin_d2 = Y4_GPIO_NUM;
config.pin_d3 = Y5_GPIO_NUM;
config.pin_d4 = Y6_GPIO_NUM;
config.pin_d5 = Y7_GPIO_NUM;
config.pin_d6 = Y8_GPIO_NUM;
config.pin_d7 = Y9_GPIO_NUM;
config.pin_xclk = XCLK_GPIO_NUM;
config.pin_pclk = PCLK_GPIO_NUM;
config.pin_vsync = VSYNC_GPIO_NUM;
config.pin_href = HREF_GPIO_NUM;
config.pin_sscb_sda = SIOD_GPIO_NUM;
config.pin_sscb_scl = SIOC_GPIO_NUM;
config.pin_pwdn = PWDN_GPIO_NUM;
config.pin_reset = RESET_GPIO_NUM;
config.xclk_freq_hz = 20000000;
config.pixel_format = PIXFORMAT_RGB565;
//init with high specs to pre-allocate larger buffers
if(psramFound()){
config.frame_size = FRAMESIZE_QVGA;
config.jpeg_quality = 12; //0-63 lower number means higher quality
config.fb_count = 2;
} else {
config.frame_size = FRAMESIZE_QVGA;
config.jpeg_quality = 12; //0-63 lower number means higher quality
config.fb_count = 2;
}
// camera init
esp_err_t err = esp_camera_init(&config);
if (err != ESP_OK) {
Serial.printf("Camera init failed with error 0x%x", err);
delay(1000);
ESP.restart();
}
// Drop down frame size for higher initial frame rate
sensor_t * s = esp_camera_sensor_get();
s->set_framesize(s, FRAMESIZE_CIF); // UXGA|SXGA|XGA|SVGA|VGA|CIF|QVGA|HQVGA|QQVGA
}
void handleNewMessages(int numNewMessages) {
Serial.print("Handle New Messages: ");
Serial.println(numNewMessages);
for (int i = 0; i < numNewMessages; i++) {
String chat_id = String(bot.messages[i].chat_id);
if (chat_id != CHAT_ID){
bot.sendMessage(chat_id, "Unauthorized user", "");
continue;
}
// Print the received message
String text = bot.messages[i].text;
Serial.println(text);
String from_name = bot.messages[i].from_name;
if (text == "/start") {
String welcome = "Welcome , " + from_name + "\n";
welcome += "Use the following commands to interact with the ESP32-CAM \n";
welcome += "/photo : takes a new photo\n";
welcome += "/flash : toggles flash LED \n";
bot.sendMessage(CHAT_ID, welcome, "");
}
if (text == "/flash") {
flashState = !flashState;
digitalWrite(FLASH_LED_PIN, flashState);
Serial.println("Change flash LED state");
}
if (text == "/photo") {
sendPhoto = true;
Serial.println("New photo request");
}
}
}
String sendPhotoTelegram() {
const char* myDomain = "api.telegram.org";
String getAll = "";
String getBody = "";
camera_fb_t * fb = NULL;
fb = esp_camera_fb_get();
if(!fb) {
Serial.println("Camera capture failed");
delay(1000);
ESP.restart();
return "Camera capture failed";
}
Serial.println("Connect to " + String(myDomain));
if (clientTCP.connect(myDomain, 443)) {
Serial.println("Connection successful");
String head = "--electroniclinic\r\nContent-Disposition: form-data; name=\"chat_id\"; \r\n\r\n" + CHAT_ID + "\r\n--electroniclinic\r\nContent-Disposition: form-data; name=\"photo\"; filename=\"esp32-cam.jpg\"\r\nContent-Type: image/jpeg\r\n\r\n";
String tail = "\r\n--electroniclinic--\r\n";
uint16_t imageLen = fb->len;
uint16_t extraLen = head.length() + tail.length();
uint16_t totalLen = imageLen + extraLen;
clientTCP.println("POST /bot"+BOTtoken+"/sendPhoto HTTP/1.1");
clientTCP.println("Host: " + String(myDomain));
clientTCP.println("Content-Length: " + String(totalLen));
clientTCP.println("Content-Type: multipart/form-data; boundary=electroniclinic");
clientTCP.println();
clientTCP.print(head);
uint8_t *fbBuf = fb->buf;
size_t fbLen = fb->len;
for (size_t n=0;n<fbLen;n=n+1024) {
if (n+1024<fbLen) {
clientTCP.write(fbBuf, 1024);
fbBuf += 1024;
}
else if (fbLen%1024>0) {
size_t remainder = fbLen%1024;
clientTCP.write(fbBuf, remainder);
}
}
clientTCP.print(tail);
esp_camera_fb_return(fb);
int waitTime = 10000; // timeout 10 seconds
long startTimer = millis();
boolean state = false;
while ((startTimer + waitTime) > millis()){
Serial.print(".");
delay(100);
while (clientTCP.available()) {
char c = clientTCP.read();
if (state==true) getBody += String(c);
if (c == '\n') {
if (getAll.length()==0) state=true;
getAll = "";
}
else if (c != '\r')
getAll += String(c);
startTimer = millis();
}
if (getBody.length()>0) break;
}
clientTCP.stop();
Serial.println(getBody);
}
else {
getBody="Connected to api.telegram.org failed.";
Serial.println("Connected to api.telegram.org failed.");
}
return getBody;
}
void setup(){
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);
// Init Serial Monitor
Serial.begin(115200);
// Set LED Flash as output
pinMode(FLASH_LED_PIN, OUTPUT);
digitalWrite(FLASH_LED_PIN, flashState);
// Config and init the camera
configInitCamera();
// Connect to Wi-Fi
WiFi.mode(WIFI_STA);
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
clientTCP.setCACert(TELEGRAM_CERTIFICATE_ROOT); // Add root certificate for api.telegram.org
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println();
Serial.print("ESP32-CAM IP Address: ");
Serial.println(WiFi.localIP());
}
void loop() {
if (sendPhoto) {
Serial.println("Preparing photo");
sendPhotoTelegram();
sendPhoto = false;
}
if (millis() > lastTimeBotRan + botRequestDelay) {
int numNewMessages = bot.getUpdates(bot.last_message_received + 1);
while (numNewMessages) {
Serial.println("got response");
handleNewMessages(numNewMessages);
numNewMessages = bot.getUpdates(bot.last_message_received + 1);
}
lastTimeBotRan = millis();
}
}
I copied the camera pin and settings from the camera.ino example but atom craches after upload the code...
ESP-ROM:esp32s3-20210327
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0x3b (SPI_FAST_FLASH_BOOT)
Saved PC:0x40376bf2
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce2820,len:0x1150
load:0x403c8700,len:0x4
load:0x403c8704,len:0xc24
load:0x403cb700,len:0x30b4
entry 0x403c88b8
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0x3b (SPI_FAST_FLASH_BOOT)
Saved PC:0x40376bf2
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce2820,len:0x1150
load:0x403c8700,len:0x4
load:0x403c8704,len:0xc24
load:0x403cb700,len:0x30b4
entry 0x403c88b8
some tips?
best regards
Hi All, I would like to play with COMX LTE and Core1 to control my stove with SMS..
all the sketches I found use Adafruit_FONA.h, but I don't know which pin I have to assign for RST...
some tips?
best regards
Hi all
I would like to play with Unit_Roller and SimpleFOC.h but I don't know how to setup the Motor configuration..
is there an Arduino example for unit_roller using SimpleFOC.h?
I'm using M5Nanoc6 as controller
this code compile but doesn't produce any motor movement.
#include "SimpleFOC.h"
#include "unit_rolleri2c.hpp"
#include <M5Unified.h>
// Create a Unit Roller object
UnitRollerI2C RollerI2C;
// Motor configuration for SimpleFOC
BLDCMotor motor = BLDCMotor(7);
BLDCDriver3PWM driver = BLDCDriver3PWM(9, 10, 11, 8);
void setup() {
M5.begin();
// Initialize the Unit Roller
if (RollerI2C.begin(&Wire, 0x64, 2, 1, 400000)) {
M5.Lcd.println("Roller initialized");
}
// Initialize the SimpleFOC driver
driver.voltage_power_supply = 12;
driver.init();
motor.linkDriver(&driver);
// Motor control mode
motor.controller = MotionControlType::velocity;
// Initialize the motor
motor.init();
motor.initFOC();
}
void loop() {
// Motor control using SimpleFOC
motor.loopFOC();
motor.move(2);
}
any tips
best regards
@kuriko thanks for the reply, as I wrote on post n. 1,
@cepics said in AtomS3R Camera & esp_camera.h example:
I can upload and run the camera.ino
for my project I need to take picture and display it in a web page....