Post topics, source code that relate to the Arduino Platform

User avatar
By Anand Lobo
#24116 Gabriel Miller at has written an excellent program for the Arduino Mega (as well as the Uno, with less accuracy) to act as a solar tracker or heliostat. This program can control multiple machines using different types of motors, uses a real-time clock to reliably calculate the Sun's position in all weather. It can only adjust one machine at any time, however.

Item 1: The program does not compile on the latest version of the Arduino IDE (1.6.5), but works fine with IDE 1.0.6

Item 2: Gabriel's solar tracker program uses something called the "BigNumber" library in order to calculate the Sun's location to a very high degree of accuracy on the Mega. It would need to be re-written for the ESP8266 in order to achieve that same level of accuracy.

Item 3: I have a couple of small machines built, that use the Arduino Mega solar tracker. But, for the price of one Mega I can get multiple ESP boards, and I would like to replace the Mega 'brain' with one ESP8266 separately controlling each machine. So in porting to the ESP8266, a lot of the program can be cut out which deals with multiple machines, because one ESP would be only used for one tracker.
This way, I can make each machine totally portable, and in addition it could be configured to get network time updates considering that the real-time clock modules I have drift by up to a minute or more over the course of a week.

I'm not the greatest programmer, which is why I'm asking for community input, particularly in porting the BigNumber library ... I'm not very familiar with a lot of the code that it uses.

Input is welcome ... and note that this could be great for developing areas. Being in India, I would like to be able to offer a pre-built simple heliostat to local residents and perhaps even get people to invest in power generation using these. I already know people who are interested in that idea.
User avatar
By Anand Lobo
#24207 So, I'm giving this a shot, with my limited coding skills.

I included the BigNumber library in an empty Arduino sketch configured for the ESP8266 (image attached), and compiling failed - I've attached the compiler output in a text file.

The warnings / errors that show up are:
Code: Select all......
/home/works/Downloads/arduino-1.6.5/libraries/BigNumber/number.c: In function 'bc_str2num':
/home/works/Downloads/arduino-1.6.5/libraries/BigNumber/number.c:1523:7: warning: assignment discards 'const' qualifier from pointer target type [enabled by default]
   ptr = str;
/home/works/Downloads/arduino-1.6.5/libraries/BigNumber/number.c:1548:7: warning: assignment discards 'const' qualifier from pointer target type [enabled by default]
   ptr = str;

Code: Select all.......
/root/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9/bin/xtensa-lx106-elf-gcc -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static -L/root/.arduino15/packages/esp8266/hardware/esp8266/1.6.4-673-g8cd3697/tools/sdk//lib -L/root/.arduino15/packages/esp8266/hardware/esp8266/1.6.4-673-g8cd3697/tools/sdk//ld -Teagle.flash.512k.ld -o /tmp/build4714199143779152163.tmp/sketch_jul25a.cpp.elf -Wl,--start-group /tmp/build4714199143779152163.tmp/sketch_jul25a.cpp.o /tmp/build4714199143779152163.tmp/BigNumber/number.c.o /tmp/build4714199143779152163.tmp/BigNumber/BigNumber.cpp.o /tmp/build4714199143779152163.tmp/BigNumberMath/BigNumberMath.cpp.o /tmp/build4714199143779152163.tmp/core.a -lm -lgcc -lhal -lphy -lnet80211 -llwip -lwpa -lmain -lpp -lsmartconfig -Wl,--end-group -L/tmp/build4714199143779152163.tmp
/root/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: /tmp/build4714199143779152163.tmp/sketch_jul25a.cpp.elf section `.text' will not fit in region `iram1_0_seg'
/tmp/build4714199143779152163.tmp/BigNumber/number.c.o: In function `_bc_do_compare$part$0$constprop$5':
number.c:(.text+0x230): undefined reference to `exit'
number.c:(.text+0x24b): undefined reference to `exit'
/tmp/build4714199143779152163.tmp/BigNumber/number.c.o: In function `new_sub_num$constprop$3':
number.c:(.text+0x288): undefined reference to `exit'
/tmp/build4714199143779152163.tmp/BigNumber/number.c.o: In function `bc_divide':
number.c:(.text+0xcb8): undefined reference to `exit'
/tmp/build4714199143779152163.tmp/BigNumber/number.c.o: In function `bc_raisemod':
number.c:(.text+0x1138): undefined reference to `exit'
/tmp/build4714199143779152163.tmp/BigNumber/number.c.o:number.c:(.text+0x1433): more undefined references to `exit' follow
/tmp/build4714199143779152163.tmp/BigNumber/number.c.o: In function `bc_sqrt':
number.c:(.text+0x14a0): undefined reference to `__ctype_ptr__'
/tmp/build4714199143779152163.tmp/BigNumber/number.c.o: In function `bc_str2num':
number.c:(.text+0x15fc): undefined reference to `exit'
collect2: error: ld returned 1 exit status
Error compiling.

Perhaps the warnings can be ignored, but from what I've been able to Google, the 'undefined reference' errors are related to some library not being included? I'm not sure how to pinpoint it.
You do not have the required permissions to view the files attached to this post.
User avatar
By Anand Lobo
#24439 No help at all? I just need help figuring out those errors above with the BigNumber library and I should be okay after that.

I don't know how to compile completely from command line or change the Arduino IDE compile options, or I'd try that. Anyone know how to determine the source of those ‘undefined reference’ errors? Google has not been my friend in resolving this.
User avatar
By martinayotte
#24472 I gave it a try ...
I didn't got much errors like you've got, but I got some such as "undefined reference to `__ctype_ptr__'" and also the famous "section `.text' will not fit in region `iram1_0_seg'".
Digging around, I've figured out that in number.c, instead of including ctype.h, it was better to include c_types.h from ESP SDK. This got it further. And for the IRAM issue, I've added on every functions of number.c, it fixed it ! :)
Running Calculate_E exemple gave the following output :
Code: Select all2.71828182845904523536028747135266249775724709369978
29 mS

Here is the modified lib in attachment.
You do not have the required permissions to view the files attached to this post.