voelkerb / STPM3X

Library for the ST Power Monitor Chip STPM32 and STPM34.
Creative Commons Zero v1.0 Universal
5 stars 1 forks source link

Hardware connections #1

Closed Zhoev1405 closed 1 month ago

Zhoev1405 commented 3 years ago

Hi,

I want to do SPI communication between ESP32 board and Eval-STPM34 metrology board , i am trying to read just a register of the Eval-STPM34 but i always fail , i used these pins to ensure the SPI communication :

ESP32 -----> EVAL-STPM34

GPIO 23 MOSI-----> MOSI

GPIO 19 MISO-----> MISO

GPIO 18 SCL -----> SCL

GPIO 5 SCS -----> SCS

GPIO 14 -----> SYN

GPIO 12 -----> RES

GND -----> GND

VCC -----> VCC

Untitled

where am i doing the mistake?

how can i do both on video https://www.youtube.com/watch?v=1S5WECN2qnI with your library

voelkerb commented 3 years ago

Hey @Zhoev1405

Your connection seems about right. Can you double check that:

Does stpm3x.init() return false, meaning that initialization has failed? I double checked that with my stpm34 eval board and I can report that the code seems to work just fine.

Have you set all Jumpers to SPI and supplied the eval board with power? You should also disconnect J4 completely.

Zhoev1405 commented 3 years ago

how can i use uart instead of spi?

voelkerb commented 2 years ago

Hey @Zhoev1405,

The library only supports SPI connection. I think ST offers a dedicated application for testing the eval board via the RS232 link.

BR Ben

Zhoev1405 commented 2 years ago

Hey @Zhoev1405,

The library only supports SPI connection. I think ST offers a dedicated application for testing the eval board via the RS232 link.

BR Ben

I connected on ESP32 and everything works well but it would be good if there was a great guide to registers I get volts and active power but how to get the network frequency? and how to calibrate?

Zhoev1405 commented 2 years ago

please tell me where to connect stpm vcc esp32 v3.3 or v5? when I connect to 5v everything works correctly and when v3.3 then stpm does not work correctly

voelkerb commented 5 months ago

My demo board uses 5V also. I am unsure as the data sheet states 3.3V should be sufficient. If you have more insides now, please advise.

aaltonen1024 commented 1 month ago

Hi, I've been trying to setup a communication between ESP32 and STPM32 evaluation board. This is how I do the wiring between them : ESP32 -----> EVAL-STPM32 GPIO 23 -----> MOSI GPIO 19 -----> MISO GPIO 18 -----> SCL GPIO 5 -----> SCS GPIO 14 -----> SYN GND -----> GND VCC -----> VCC

you said to disconnect J4 completely. Does that mean I should remove the jumper, and connect GPIO 12 to 'En' pin ? I also put my VCC to 5V on ESP32, but I got this numbers every time ( I haven't connect the sensor to a power source yet ). Is this an expected behavior?

image

voelkerb commented 1 month ago

@aaltonen1024 Yes, exactly. Remove the jumper and connect the En pin, which is the 4th pin on J5 to whatever you defined as the RES pin. Make sure you supply power to the board on J5 (VCC, GND) as well. The inputs should wiggle a little bit. Fixed values like you get indicate that sth. is not correctly wired. You can also hook up an oscilloscope/LA and see if the chip responds.

aaltonen1024 commented 1 month ago

I still can't get it right even after removing the jumper on J4 and connect the En pin to RES pin. I must be getting something wrong. Just to clarify,

Here's how I assume how the J6 pins are positioned by seeing the little number '1' on the top right corner diagram J5

and here's the pin list from the datasheet J5 PINS

and I assume the same layout is also used for J5 digital pins?

voelkerb commented 1 month ago

I used the eval board schematics below for all my testing. This shows the layout and numbering of the header. The position of pin 1 is marked on the eval board.

image

Can you hook up a logic analyser or oscilloscope to the SPI lines to see if you get an answer on the MISO line?

Other things to look out for:

Unfortunately I don't have an eval board at hand ATM. Wiring should however be in line with this schematic (page 2 + 3).

aaltonen1024 commented 1 month ago

I got it to work now, it's gotta be faulty wires because I replaced them all. Thank you for your help

voelkerb commented 1 month ago

You're welcome. I think I will close the issue.