我的網誌清單

2023年2月13日星期一

Arduino projects

atmega2560


Complete pinout diagram for the Arduino Mega 2560, showing all digital, analog, and power pins.

atmega 2560







Serial adapter

QinHeng Bus 003 Device 002: ID 1a86:7523 QinHeng Electronics CH340 serial converte
r
CH340 USB TO SERIAL TTL ADAPTER WITH 5/3V JUMPER
£1.29
 £1.99
 
 
VAT included

A CH340 based USB to serial TTL adapter. This module makes use of the common CH340 USB interface IC to provide a low cost alternative to the FTDI adapter. It also has the additional feature of being able to select 3.3V*/5V TTL levels by linking the VCC pin to either the 3.3V pin or 5V pin using the supplied jumper.

Note: This module is not suitable for use with ESP modules. Please see alternative item HCMODU0076 instead.

Pinnout:

1….5V (USB)
2….VCC (Input, connect to 5V or 3V3 pin via jumper)
3….3V3 (*measured at 3.67V)
4….TXD
5….RXD
6….GND


SPI Flash







forum has the resistor voltage devider instead of level shifter

1 mb flash read write

SD FAT block buff read write on forum , a lot of good information


https://elm-chan.org/fsw/ff/.   elm-chan fat system documentation

https://elm-chan.org/docs/fat_e.html.  very detailed explanation of FAT



https://github.com/khoih-prog/FTP_Server_Teensy41.   teensy but very similar to simpleftpserver


SPI is a full-duplex, bi-directional bus where data is both sent to the slave and received from the slave at the same time. Your SPI controller doesn't know if a given byte is glong from the master, or from the slave, or both. Therefore, whenever you send a byte, you must also read a byte, if only to throw it away. By the same token, you cannot receive a byte without sending a byte, even if the slave will throw it away.

Take a look at Wikipedia.

So, what you code is doing is

  1. Sending Read_ID to the slave.
  2. Reading and throwing away the byte simultaneously read out of the slave.
  3. Write 0 to the slave to enable the slave to send a byte of data.
  4. Read the data byte that was simultaneously read out of the slave.
  5. Loop back to #3.

By the way, such questions would be better suited for the EE Stack Exchange as it is more about the hardware protocol as opposed to programming.



a description on how to read write flash memory on esp32

esp32-flash-memory-spi-flash-arduino



https://stackoverflow.com/questions/36206794/spi-data-write-read

certain examples writing and reading from to spi flash in c

https://github.com/Xilinx/embeddedsw/tree/master/XilinxProcessorIPLib/drivers/spi/examples


sd card fatfs is much easier. though in stm32 mx platform

https://deepbluembedded.com/stm32-sd-card-spi-fatfs-tutorial-examples/


esp-idf forum has a pretty complete recommendation to deal with FAT on flash

https://esp32.com/viewtopic.php?t=43906


https://forum.arduino.cc/t/fatfs-for-external-flash-memory/1335861. esp32 on arduino


https://learn.adafruit.com/adafruit-hallowing/using-spi-flash.  use circuitpython to read write files




circuit python

https://circuitpython.org/downloads?q=stm32



https://github.com/ESP32-S3_SD_Card.   esp32 sd card


doc on vfs deployment

https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/storage/vfs.html


transfer files over serial



https://forum.pjrc.com/index.php?threads/copy-files-usb-to-sd-sd-to-usb-from-2-inputs-in-simple-msc-example.77401/


Text file transfer between PC and Arduino using Batch scripts - Other Hardware / Storage - Arduino Forum


https://stackoverflow.com/questions/4178168/how-to-programmatically-move-copy-and-delete-files-and-directories-on-sd.     some good example codes


https://forum.arduino.cc/t/functions-to-wrap-fatfs-on-arduino/272413/18  sdfat vs fatfs

another library


ring buffer  1 PAGE = 256Bytes    buffer size = 4 pages

Releases · shabaz123/spi_flash    binary file only
article below:-






it may be the way you go little FS








parsing data over serial


esp32 ftp client

esp32 ftp server

esp8266 ftp server

https://github.com/Neutrino-1/Wireless_SD.              wireless sd card reader thru ftp

async webserver with sd card write





Serial problem on stm32


  • Serial1 prints to hardware USART 1*
  • Serial2 prints to hardware USART 2*

stm32 OTA upload with esp8266 wifi



serial flash library

that could be the solution


FTP

ftp server for mac






File transfer over serial




Python codes


Releases · shabaz123/spi_flash    github for above



USB army knife





Webserver




https://github.com/khoih-prog/EthernetWebServer.  suits many boards, including stm32










control cross domains is another story




A series of tutorials vue.js.  javascripts


Mako webserver

https://github.com/RealTimeLogic/BAS.  3 licenses, not completely free



Lua Fast-Tracks Embedded Web Application Development       Lua + web development steep learning 


LSP + htmx: A Powerful Duo for Embedded Web Apps    sounds like a simple solution, but still to read




Installing Mako Server as a Service on Linux             install mako as a service in linux

Setting up a Low Cost SMQ IoT Broker                    connect 10000 iot on the cloud 




https://tutorial.realtimelogic.com/rtl/.       xedge is an online IDE not locally hosted,




a very robust project ESP32




FTP

https://github.com/gallegojm/Arduino-Ftp-Server.   this one may suit my usage case


https://github.com/xreef/simpleftpserver/issues/72.  upload stalls. user provided his script

another C


ftp upload issue





https://github.com/Industrial-Shields/arduino-FTP.   another simple server..  using stream()


https://github.com/dplasa/FTPClientServer.    server and client on the same boat




https://github.com/pschatzmann/TinyFTPClient.  FTP client small size may do the job easily




 This may be a simple solution to download file to spi flash?


https://github.com/8-DK/ESP32_FTP_SDCARD.   esp32 ftp client for sd card



https://github.com/karolis1115/FTPduino.        client esp8266

https://github.com/littlefs-project/littlefs.    littls Fs. many other fs mentioned.  spiffs

https://github.com/SimKT/ESP32-Fast-FTP.   esp32 ftp server for sd card





SPI flash

rp2040 SPI 0 and SPI 1 pin assignment     -----******-----

I also added these lines to setup to initialize SPI0 and SPI1 on pins I need

void setup(void) { SPI.setRX(0); // (RP2040 ZERO pin 0, 4) SPI.setCS(1); // (RP2040 ZERO pin 1, 5, 17) SPI.setSCK(2); // (RP2040 ZERO pin 2, 6, 18) SPI.setTX(3); // (RP2040 ZERO pin 3, 7, 19) SPI.begin(); SPI1.setRX(12); // (RP2040 ZERO pin 8, 12) SPI1.setCS(13); // (RP2040 ZERO pin 9, 13) SPI1.setSCK(14); // (RP2040 ZERO pin 10, 14) SPI1.setTX(15); // (RP2040 ZERO pin 11, 15) SPI1.begin(); }


SPIflash - Rinky-Dink Electronics    electronic engineer solution  new website

 






2 gauges on a page, gauge github links

gauge blog









ADC







good explanation on which mode is working....   again MX platform

https://embedds.com/multichannel-adc-using-dma-on-stm32/.   codes pretty close to arduino based




https://github.com/afiskon/stm32-multi-channel-adc.     shown on display , again MX

https://visualgdb.com/tutorials/arm/stm32/adc/.      codes and colorful plots

https://blog.embeddedexpert.io/?p=1443.    I like to see how to set the registries







https://github.com/Darouez-Oussama/stm32u5-ADC-DMA.     a good one with codes   DMA circular






stm32f4 example library Stm32F4_ADC built in 




sample codes: adc with dma

#include <STM32ADC.h>


const int adcPin = PA0; // ADC pin


const int bufferSize = 100; // Size of the DMA buffer


uint16_t adcBuffer[bufferSize]; // DMA buffer


STM32ADC myADC(ADC1);

 

void setup() {


  Serial.begin(9600);


  // Initialize the ADC pin


  pinMode(adcPin, INPUT_ANALOG);


  // Initialize the ADC


  myADC.begin();


  myADC.setSampleRate(ADC_SMPR_1_5); // Set the ADC sample rate


  // Start ADC with DMA


  myADC.startContinuous(adcPin, adcBuffer, bufferSize);


}


void loop() {


  // Wait for DMA transfer to complete


  if (myADC.isContinuousDMAComplete()) {


    // Process the data in adcBuffer


    for (int i = 0; i < bufferSize; i++) {


      Serial.println(adcBuffer[i]);


    }


    // Restart the DMA transfer


    myADC.restartContinuous();


  }


}


-----------------------------------------------------------------------------------------------------------
arduino based codes found from above



SD cards















my sd shield connection  MISO = 11, MOSI=12, CS=4 or other, SCK=13
SPI tested ok Clock set to 4mhz

All standard library did not work



atmel spi doc


stm32 sdcard example



troubleshooting












don't init ot begin with it.  testing read write before hand.




Max485

I have LC Electronics Max486 board $10 5 pcs on ebay


AC line and power monitoring

ZMPT101





AC current sensing



Arduino Based Clamp Meter Circuit




open energy burden resistor = 33ohms plus calculations.









https://github.com/danpeig/ESP32EnergyMonitor.   though esp32  calibration code are for all.

pzem-004t modbus TTL or rs485 interface



CT types and burden resistors, must read !

voltage divider calculator:---

20PCS New Design 5A Range Current Detect Sensor Modules ACS712 For NEW    US $28.36   ebay



current only sketch only

voltage and current









Sympte timecode generator

schematic







monitoring AC mains


  • IMG_3908

    ct-sensors-circuit1.png




  • Multi-functions Shield
It has a library


a lot of examples, but none works
https://github.com/hpsaturn/MultiFuncShield-Library.    most reliable example codes --- good
Multi-Function-Shield_STM32-HAL.    stm32? stick to Nucleo board



  • Frequency Counter
  • Building , Schematic and Code

preamp








沒有留言:

發佈留言